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

@@ -4,7 +4,8 @@
v{{ version || '-' }}
<span v-if="hasNewVersion" class="update-badge"></span>
</div>
<el-dialog v-model="show" width="522px" :close-on-click-modal="false" align-center class="update-dialog"
<el-dialog v-model="show" width="522px" :close-on-click-modal="false" align-center
:class="['update-dialog', `stage-${stage}`]"
:title="stage === 'downloading' ? `正在更新 ${appName}` : '软件更新'">
<div v-if="stage === 'check'" class="update-content">
<div class="update-layout">
@@ -48,7 +49,7 @@
</div>
<div class="download-content">
<div class="download-info">
<p>正在下载更新</p>
<p>正在下载安装...</p>
</div>
<div class="download-progress">
<el-progress
@@ -65,26 +66,29 @@
</div>
</div>
<div v-else-if="stage === 'completed'" class="update-content">
<div class="update-header text-center">
<img src="/icon/icon.png" class="app-icon" alt="App Icon"/>
<h3>更新完成</h3>
<p>更新文件已下载将在重启后自动应用</p>
</div>
<div class="download-progress">
<div class="progress-info">
<span>{{ prog.current }} / {{ prog.total }}</span>
<div class="download-main">
<div class="download-icon">
<img src="/icon/icon.png" class="app-icon" alt="App Icon"/>
</div>
<div class="download-content">
<div class="download-info">
<p>可以开始安装了</p>
</div>
<div class="download-progress">
<el-progress
:percentage="100"
:show-text="false"
:stroke-width="6"
color="#67C23A"/>
<div class="progress-details">
<span style="font-weight: 500" v-if="prog.current !== '0 MB' && prog.total !== '0 MB'">{{ prog.current }} / {{ prog.total }}</span>
<span style="font-weight: 500" v-else>下载完成</span>
<div class="action-buttons">
<el-button size="small" type="primary" @click="installUpdate">立即重启</el-button>
</div>
</div>
</div>
</div>
<el-progress
:percentage="100"
:show-text="false"
:stroke-width="6"
color="#67C23A"/>
</div>
<div class="update-buttons">
<el-button @click="cancelDownload">稍后更新</el-button>
<el-button type="primary" @click="installUpdate">重启应用新版本</el-button>
</div>
</div>
</el-dialog>
@@ -92,7 +96,7 @@
</template>
<script setup lang="ts">
import {ref, computed, onMounted, onUnmounted} from 'vue'
import {ref, computed, onMounted, onUnmounted, watch} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus'
import {updateApi} from '../../api/update'
@@ -109,11 +113,13 @@ const stage = ref<Stage>('check')
const appName = ref('我了个电商')
const version = ref('')
const hasNewVersion = ref(false) // 控制小红点显示
const prog = ref({percentage: 0, current: '0 MB', total: '0 MB', speed: ''})
const prog = ref({percentage: 0, current: '0 MB', total: '0 MB'})
const info = ref({
latestVersion: '2.4.8',
downloadUrl: '',
updateNotes: '• 优化了用户界面体验\n• 修复了已知问题\n• 提升了系统稳定性\n• 增加了新的功能模块\n• 优化了数据处理性能',
asarUrl: '',
jarUrl: '',
updateNotes: '• 优化了用户界面体验\n• 修复了已知问题\n• 提升了系统稳定性',
currentVersion: '',
hasUpdate: false
})
@@ -140,7 +146,9 @@ async function autoCheck(silent = false) {
currentVersion: result.currentVersion,
latestVersion: result.latestVersion,
downloadUrl: result.downloadUrl || '',
updateNotes: '• 优化了用户界面体验\n• 修复了已知问题\n• 提升了系统稳定性\n• 轻量级更新仅替换app.asar',
asarUrl: result.asarUrl || '',
jarUrl: result.jarUrl || '',
updateNotes: '• 优化了用户界面体验\n• 修复了已知问题\n• 提升了系统稳定性\n• 同步更新前端和后端',
hasUpdate: true
}
hasNewVersion.value = true
@@ -176,8 +184,10 @@ async function autoCheck(silent = false) {
function handleVersionClick() {
// 如果有新版本,直接显示更新对话框
if (hasNewVersion.value) {
show.value = true
// 重置状态确保从检查阶段开始
stage.value = 'check'
prog.value = {percentage: 0, current: '0 MB', total: '0 MB'}
show.value = true
} else {
// 没有新版本,执行检查更新
autoCheck(false)
@@ -196,29 +206,35 @@ function remindLater() {
}
async function start() {
if (!info.value.downloadUrl) {
if (!info.value.asarUrl && !info.value.jarUrl) {
ElMessage.error('下载链接不可用')
return
}
stage.value = 'downloading'
prog.value = {percentage: 0, current: '0 MB', total: '0 MB', speed: ''}
prog.value = {percentage: 0, current: '0 MB', total: '0 MB'}
;(window as any).electronAPI.onDownloadProgress((progress: any) => {
prog.value = {
percentage: progress.percentage || 0,
current: progress.current || '0 MB',
total: progress.total || '0 MB',
speed: progress.speed || ''
total: progress.total || '0 MB'
}
})
try {
const response = await (window as any).electronAPI.downloadUpdate(info.value.downloadUrl)
const response = await (window as any).electronAPI.downloadUpdate({
asarUrl: info.value.asarUrl,
jarUrl: info.value.jarUrl
})
if (response.success) {
stage.value = 'completed'
prog.value.percentage = 100
// 如果没有有效的进度信息,设置默认值
if (prog.value.current === '0 MB' && prog.value.total === '0 MB') {
// 保持原有的"0 MB"值,让模板中的条件判断来处理显示
}
ElMessage.success('下载完成')
} else {
ElMessage.error('下载失败: ' + (response.error || '未知错误'))
@@ -270,6 +286,15 @@ onMounted(async () => {
await autoCheck(true)
})
// 监听对话框关闭,重置状态
watch(show, (newValue) => {
if (!newValue) {
// 对话框关闭时重置状态
stage.value = 'check'
prog.value = {percentage: 0, current: '0 MB', total: '0 MB'}
}
})
onUnmounted(() => {
(window as any).electronAPI.removeDownloadProgressListener()
})
@@ -320,11 +345,39 @@ onUnmounted(() => {
box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}
:deep(.update-dialog .el-dialog__header) {
/* 通用标题样式 */
:deep(.update-dialog .el-dialog__title) {
font-size: 14px;
font-weight: 500;
margin-left: 8px;
}
/* 默认标题样式(第一阶段 - 检查阶段) */
:deep(.update-dialog.stage-check .el-dialog__header) {
display: block;
text-align: left;
}
/* 第二阶段 - 下载中,标题居中 */
:deep(.update-dialog.stage-downloading .el-dialog__header) {
display: block;
text-align: center;
}
:deep(.update-dialog.stage-downloading .el-dialog__title) {
margin-left: 20px;
}
/* 第三阶段 - 下载完成,标题居中 */
:deep(.update-dialog.stage-completed .el-dialog__header) {
display: block;
text-align: center;
}
:deep(.update-dialog.stage-completed .el-dialog__title) {
margin-left: 20px;
}
:deep(.update-dialog .el-dialog__body) {
padding: 0;
}
@@ -538,6 +591,11 @@ onUnmounted(() => {
color: #909399;
}
.action-buttons {
display: flex;
gap: 8px;
}
:deep(.el-progress-bar__outer) {
border-radius: 4px;
background-color: #e5e7eb;