Skip to content

Commit 0739fa2

Browse files
authored
Merge pull request #964 from xinnan-tech/update-fix
fix:取消docker版上传ota固件时默认的文件大小限制
2 parents edc601c + 3c62ada commit 0739fa2

File tree

4 files changed

+117
-27
lines changed

4 files changed

+117
-27
lines changed

Dockerfile-web

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN apt-get update && \
2323
rm -rf /var/lib/apt/lists/*
2424

2525
# 配置Nginx
26-
COPY docs/docker/nginx.conf /etc/nginx/conf.d/default.conf
26+
COPY docs/docker/nginx.conf /etc/nginx/nginx.conf
2727

2828
# 复制前端构建产物
2929
COPY --from=web-builder /app/dist /usr/share/nginx/html

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p align="center">
77
本项目为开源智能硬件项目
88
<a href="https://github.com/78/xiaozhi-esp32">xiaozhi-esp32</a>提供后端服务<br/>
9-
根据<a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">小智通信协议</a>使用Python实现<br/>
9+
根据<a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">小智通信协议</a>使用Python、Java、Vue实现<br/>
1010
帮助您快速搭建小智服务器
1111
</p>
1212

@@ -15,7 +15,8 @@
1515
· 简体中文
1616
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/releases">更新日志</a>
1717
· <a href="./README.md#%E9%83%A8%E7%BD%B2%E6%96%87%E6%A1%A3">部署文档</a>
18-
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/issues ">反馈问题</a>
18+
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/issues">反馈问题</a>
19+
· <a href="./docs/FAQ.md">常见问题</a>
1920
</p>
2021
<p align="center">
2122
<a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/releases">

docs/docker/nginx.conf

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,53 @@
1-
server {
2-
listen 8002;
3-
server_name localhost;
4-
5-
# 静态资源服务(Vue项目)
6-
location / {
7-
root /usr/share/nginx/html;
8-
try_files $uri $uri/ /index.html;
9-
}
1+
user root;
2+
worker_processes 4;
3+
4+
events {
5+
worker_connections 1024;
6+
}
7+
8+
http {
9+
include mime.types;
10+
default_type application/octet-stream;
11+
sendfile on;
12+
keepalive_timeout 300;
13+
client_header_timeout 180s;
14+
client_body_timeout 180s;
15+
client_max_body_size 1024M;
16+
17+
gzip on;
18+
gzip_buffers 32 4K;
19+
gzip_comp_level 6;
20+
gzip_min_length 100;
21+
gzip_types application/javascript text/css text/xml image/jpeg image/gif image/png;
22+
gzip_disable "MSIE [1-6]\.";
23+
gzip_vary on;
24+
25+
server {
26+
# 无域名访问,就用localhost
27+
server_name localhost;
28+
# 80端口
29+
listen 8002;
30+
31+
# 转发到编译后到web目录
32+
location / {
33+
root /usr/share/nginx/html;
34+
try_files $uri $uri/ /index.html;
35+
}
1036

11-
# API反向代理(Java项目)
12-
location /xiaozhi/ {
13-
proxy_pass http://127.0.0.1:8003;
14-
proxy_set_header Host $host;
15-
proxy_cookie_path /api/ /;
16-
proxy_set_header Referer $http_referer;
17-
proxy_set_header Cookie $http_cookie;
37+
# 转发到manager-api
38+
location /xiaozhi/ {
39+
proxy_pass http://127.0.0.1:8003;
40+
proxy_set_header Host $host;
41+
proxy_cookie_path /manager/ /;
42+
proxy_set_header Referer $http_referer;
43+
proxy_set_header Cookie $http_cookie;
1844

19-
proxy_connect_timeout 10;
20-
proxy_send_timeout 10;
21-
proxy_read_timeout 10;
45+
proxy_connect_timeout 10;
46+
proxy_send_timeout 10;
47+
proxy_read_timeout 10;
2248

23-
proxy_set_header X-Real-IP $remote_addr;
24-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49+
proxy_set_header X-Real-IP $remote_addr;
50+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
51+
}
2552
}
2653
}

main/manager-web/src/components/FirmwareDialog.vue

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-dialog :title="title" :visible.sync="visible" width="500px" @close="handleClose">
2+
<el-dialog :title="title" :visible.sync="visible" width="500px" @close="handleClose" @open="handleOpen">
33
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
44
<el-form-item label="固件名称" prop="firmwareName">
55
<el-input v-model="form.firmwareName" placeholder="请输入固件名称(板子+版本号)"></el-input>
@@ -13,11 +13,14 @@
1313
<el-input v-model="form.version" placeholder="请输入版本号(x.x.x格式)"></el-input>
1414
</el-form-item>
1515
<el-form-item label="固件文件" prop="firmwarePath">
16-
<el-upload class="upload-demo" action="#" :http-request="handleUpload" :before-upload="beforeUpload"
17-
:accept="'.bin,.apk'" :limit="1" :multiple="false" :auto-upload="true">
16+
<el-upload ref="upload" class="upload-demo" action="#" :http-request="handleUpload"
17+
:before-upload="beforeUpload" :accept="'.bin,.apk'" :limit="1" :multiple="false" :auto-upload="true"
18+
:on-remove="handleRemove">
1819
<el-button size="small" type="primary">点击上传</el-button>
1920
<div slot="tip" class="el-upload__tip">只能上传固件文件(.bin/.apk),且不超过100MB</div>
2021
</el-upload>
22+
<el-progress v-if="isUploading || uploadStatus === 'success'" :percentage="uploadProgress"
23+
:status="uploadStatus"></el-progress>
2124
</el-form-item>
2225
<el-form-item label="备注" prop="remark">
2326
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注信息"></el-input>
@@ -53,6 +56,9 @@ export default {
5356
data() {
5457
return {
5558
firmwareTypes: FIRMWARE_TYPES,
59+
uploadProgress: 0,
60+
uploadStatus: '',
61+
isUploading: false,
5662
rules: {
5763
firmwareName: [
5864
{ required: true, message: '请输入固件名称(板子+版本号)', trigger: 'blur' }
@@ -108,16 +114,72 @@ export default {
108114
},
109115
handleUpload(options) {
110116
const { file } = options
117+
this.uploadProgress = 0
118+
this.uploadStatus = ''
119+
this.isUploading = true
120+
121+
// 使用setTimeout实现简单的0-50%过渡
122+
const timer = setTimeout(() => {
123+
if (this.uploadProgress < 50) { // 只有当进度小于50%时才设置
124+
this.uploadProgress = 50
125+
}
126+
}, 1000)
127+
111128
Api.ota.uploadFirmware(file, (res) => {
129+
clearTimeout(timer) // 清除定时器
112130
res = res.data
113131
if (res.code === 0) {
114132
this.form.firmwarePath = res.data
115133
this.form.size = file.size
134+
this.uploadProgress = 100
135+
this.uploadStatus = 'success'
116136
this.$message.success('固件文件上传成功')
137+
// 延迟2秒后隐藏进度条
138+
setTimeout(() => {
139+
this.isUploading = false
140+
}, 2000)
117141
} else {
142+
this.uploadStatus = 'exception'
118143
this.$message.error(res.msg || '文件上传失败')
144+
this.isUploading = false
145+
}
146+
}, (progressEvent) => {
147+
if (progressEvent.total) {
148+
const progress = Math.round((progressEvent.loaded * 100) / progressEvent.total)
149+
// 只有当进度大于50%时才更新
150+
if (progress > 50) {
151+
this.uploadProgress = progress
152+
}
153+
// 如果上传完成但还没收到成功响应,保持进度条显示
154+
if (progress === 100) {
155+
this.uploadStatus = ''
156+
}
119157
}
120158
})
159+
},
160+
handleRemove() {
161+
this.form.firmwarePath = ''
162+
this.form.size = 0
163+
this.uploadProgress = 0
164+
this.uploadStatus = ''
165+
this.isUploading = false
166+
},
167+
handleOpen() {
168+
// 重置上传相关状态
169+
this.uploadProgress = 0
170+
this.uploadStatus = ''
171+
this.isUploading = false
172+
// 重置表单中的文件相关字段
173+
if (!this.form.id) { // 只在新增时重置
174+
this.form.firmwarePath = ''
175+
this.form.size = 0
176+
// 重置上传组件
177+
this.$nextTick(() => {
178+
if (this.$refs.upload) {
179+
this.$refs.upload.clearFiles()
180+
}
181+
})
182+
}
121183
}
122184
}
123185
}

0 commit comments

Comments
 (0)