fix(client): 设备移除逻辑与认证流程优化

- 修改设备移除时的本地清理方法,统一调用 clearLocalAuth
- 优化设备数量限制校验逻辑,避免重复计算当前设备- 移除冗余的设备状态检查,简化设备移除流程- 调整 Redis 连接超时与等待时间,提升连接稳定性- 增强 MySQL 数据库连接配置,添加自动重连机制
-优化 Druid 连接池参数,提高数据库连接性能
- 简化客户端认证与数据上报逻辑,提升处理效率
- 移除过期设备状态更新逻辑,减少不必要的数据库操作- 调整慢 SQL 记录阈值,便于及时发现性能问题-优化版本分布与数据类型统计查询逻辑,提高响应速度
This commit is contained in:
2025-10-15 18:32:48 +08:00
parent f614860eee
commit 6f04658265
29 changed files with 702 additions and 1010 deletions

View File

@@ -32,6 +32,7 @@ export function uploadFile(data) {
}
// 更新版本信息和下载链接
// data: { version, asarUrl, jarUrl }
export function updateVersion(data) {
return request({
url: '/system/version/update',

View File

@@ -21,9 +21,14 @@
<el-descriptions-item label="更新时间">
{{ parseTime(versionInfo.updateTime) }}
</el-descriptions-item>
<el-descriptions-item label="下载链接" v-if="versionInfo.downloadUrl">
<el-link :href="versionInfo.downloadUrl" target="_blank" type="primary">
{{ versionInfo.downloadUrl }}
<el-descriptions-item label="ASAR下载链接" v-if="versionInfo.asarUrl">
<el-link :href="versionInfo.asarUrl" target="_blank" type="primary">
{{ versionInfo.asarUrl }}
</el-link>
</el-descriptions-item>
<el-descriptions-item label="JAR下载链接" v-if="versionInfo.jarUrl">
<el-link :href="versionInfo.jarUrl" target="_blank" type="success">
{{ versionInfo.jarUrl }}
</el-link>
</el-descriptions-item>
</el-descriptions>
@@ -34,25 +39,40 @@
<!-- 上传对话框 -->
<el-dialog title="上传新版本" :visible.sync="uploadVisible" width="500px" append-to-body>
<el-form ref="uploadForm" :model="uploadForm" :rules="uploadRules" label-width="80px">
<el-form ref="uploadForm" :model="uploadForm" :rules="uploadRules" label-width="100px">
<el-form-item label="版本号" prop="version">
<el-input v-model="uploadForm.version" placeholder="请输入版本号2.1.0"></el-input>
<el-input v-model="uploadForm.version" placeholder="请输入版本号2.4.7"></el-input>
</el-form-item>
<el-form-item label="版本文件" prop="file">
<el-form-item label="ASAR文件" prop="asarFile">
<el-upload
ref="upload"
ref="asarUpload"
action="#"
:limit="1"
accept=".asar"
:on-exceed="handleExceed"
:file-list="fileList"
:on-exceed="handleAsarExceed"
:file-list="asarFileList"
:auto-upload="false"
:on-change="handleFileChange"
:on-remove="handleFileRemove">
<el-button slot="trigger" size="small" type="primary">选择文件</el-button>
:on-change="handleAsarFileChange"
:on-remove="handleAsarFileRemove">
<el-button slot="trigger" size="small" type="primary">选择ASAR文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传asar文件且不超过800MB</div>
</el-upload>
</el-form-item>
<el-form-item label="JAR文件" prop="jarFile">
<el-upload
ref="jarUpload"
action="#"
:limit="1"
accept=".jar"
:on-exceed="handleJarExceed"
:file-list="jarFileList"
:auto-upload="false"
:on-change="handleJarFileChange"
:on-remove="handleJarFileRemove">
<el-button slot="trigger" size="small" type="success">选择JAR文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传jar文件且不超过200MB</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="uploadVisible = false"> </el-button>
@@ -77,7 +97,8 @@ export default {
versionInfo: {
currentVersion: '2.0.0',
updateTime: null,
downloadUrl: null
asarUrl: null,
jarUrl: null
},
// 版本检查表单
checkForm: {
@@ -92,20 +113,19 @@ export default {
// 上传表单
uploadForm: {
version: '',
file: null
asarFile: null,
jarFile: null
},
// 上传规则
uploadRules: {
version: [
{ required: true, message: "版本号不能为空", trigger: "blur" },
{ pattern: /^\d+\.\d+\.\d+$/, message: "版本号格式不正确应为x.y.z格式", trigger: "blur" }
],
file: [
{ required: true, message: "请选择要上传的文件", trigger: "change" }
]
},
// 文件列表
fileList: [],
asarFileList: [],
jarFileList: [],
// 上传加载状态
uploadLoading: false,
// 上传进度
@@ -132,59 +152,106 @@ export default {
resetUploadForm() {
this.uploadForm = {
version: '',
file: null
asarFile: null,
jarFile: null
};
this.fileList = [];
this.asarFileList = [];
this.jarFileList = [];
this.uploadProgress = 0;
if (this.$refs.uploadForm) {
this.$refs.uploadForm.resetFields();
}
},
/** 文件超出限制 */
handleExceed() {
this.$modal.msgError("只能选择一个文件");
/** ASAR文件超出限制 */
handleAsarExceed() {
this.$modal.msgError("只能选择一个ASAR文件");
},
/** 文件改变 */
handleFileChange(file, fileList) {
this.uploadForm.file = file.raw;
this.fileList = fileList;
/** ASAR文件改变 */
handleAsarFileChange(file, fileList) {
this.uploadForm.asarFile = file.raw;
this.asarFileList = fileList;
},
/** 文件移除 */
handleFileRemove() {
this.uploadForm.file = null;
this.fileList = [];
/** ASAR文件移除 */
handleAsarFileRemove() {
this.uploadForm.asarFile = null;
this.asarFileList = [];
},
/** JAR文件超出限制 */
handleJarExceed() {
this.$modal.msgError("只能选择一个JAR文件");
},
/** JAR文件改变 */
handleJarFileChange(file, fileList) {
this.uploadForm.jarFile = file.raw;
this.jarFileList = fileList;
},
/** JAR文件移除 */
handleJarFileRemove() {
this.uploadForm.jarFile = null;
this.jarFileList = [];
},
/** 提交上传 */
submitUpload() {
this.$refs.uploadForm.validate(valid => {
if (valid) {
if (!this.uploadForm.file) {
this.$modal.msgError("请选择要上传的文件");
if (!this.uploadForm.asarFile && !this.uploadForm.jarFile) {
this.$modal.msgError("请至少选择一个文件上传");
return;
}
if (this.uploadForm.file.size > 800 * 1024 * 1024) {
this.$modal.msgError("文件大小不能超过800MB");
return;
// 验证ASAR文件
if (this.uploadForm.asarFile) {
if (this.uploadForm.asarFile.size > 800 * 1024 * 1024) {
this.$modal.msgError("ASAR文件大小不能超过800MB");
return;
}
if (!this.uploadForm.asarFile.name.endsWith('.asar')) {
this.$modal.msgError("只支持上传.asar文件");
return;
}
}
if (!this.uploadForm.file.name.endsWith('.asar')) {
this.$modal.msgError("只支持上传.asar文件");
return;
// 验证JAR文件
if (this.uploadForm.jarFile) {
if (this.uploadForm.jarFile.size > 200 * 1024 * 1024) {
this.$modal.msgError("JAR文件大小不能超过200MB");
return;
}
if (!this.uploadForm.jarFile.name.endsWith('.jar')) {
this.$modal.msgError("只支持上传.jar文件");
return;
}
}
this.uploadLoading = true;
const formData = new FormData();
formData.append('files', this.uploadForm.file);
if (this.uploadForm.asarFile) {
formData.append('files', this.uploadForm.asarFile);
}
if (this.uploadForm.jarFile) {
formData.append('files', this.uploadForm.jarFile);
}
uploadFile(formData).then(response => {
if (response && response.data[0]) {
const fileInfo = response.data[0];
const downloadUrl = fileInfo.fileUrl || fileInfo.url;
if (response && response.data) {
let asarUrl = null;
let jarUrl = null;
// 解析上传结果
response.data.forEach(fileInfo => {
const url = fileInfo.fileUrl || fileInfo.url;
if (fileInfo.fileName && fileInfo.fileName.endsWith('.asar')) {
asarUrl = url;
} else if (fileInfo.fileName && fileInfo.fileName.endsWith('.jar')) {
jarUrl = url;
}
});
updateVersion({
version: this.uploadForm.version,
downloadUrl: downloadUrl
asarUrl: asarUrl,
jarUrl: jarUrl
}).then(() => {
this.$modal.msgSuccess("版本文件上传成功");
this.uploadVisible = false;