feat(electron): 实现系统托盘和关闭行为配置功能

- 添加系统托盘创建和销毁逻辑- 实现窗口关闭行为配置(退出/最小化/托盘)
- 添加配置文件读写功能
- 实现下载取消和清理功能
- 添加待更新文件检查机制
- 优化文件下载进度和错误处理
- 添加自动更新配置选项- 实现平滑滚动动画效果
- 添加试用期过期类型检查
-优化VIP状态刷新逻辑
This commit is contained in:
2025-10-17 14:17:47 +08:00
parent 6e1b4d00de
commit 07e34c35c8
19 changed files with 1545 additions and 467 deletions

View File

@@ -82,19 +82,25 @@
<el-table-column label="ID" align="center" prop="id" width="80" />
<el-table-column label="账号名称" align="center" prop="accountName" :show-overflow-tooltip="true" />
<el-table-column label="用户名" align="center" prop="username" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status">
<el-table-column label="状态" align="center" prop="status" width="80">
<template slot-scope="scope">
<dict-tag :options="statusOptions" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="过期时间" align="center" prop="expireTime" width="180">
<el-table-column label="账号类型" align="center" prop="accountType" width="90">
<template slot-scope="scope">
<el-tag :type="scope.row.accountType === 'paid' ? 'success' : 'warning'" size="small">
{{ scope.row.accountType === 'paid' ? '付费' : '试用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="过期时间" align="center" prop="expireTime" width="130">
<template slot-scope="scope">
<el-tag
:type="getRemainingDays(scope.row).type"
:type="getRemainingDays(scope.row.expireTime).type"
size="small"
style="margin-top: 5px;"
>
{{ getRemainingDays(scope.row).text }}
{{ getRemainingDays(scope.row.expireTime).text }}
</el-tag>
</template>
</el-table-column>
@@ -104,7 +110,7 @@
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template slot-scope="scope">
<el-button
size="mini"
@@ -113,6 +119,12 @@
@click="handleUpdate(scope.row)"
v-hasPermi="['monitor:account:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-mobile-phone"
@click="viewDevices(scope.row)"
>设备</el-button>
<el-button
size="mini"
type="text"
@@ -206,6 +218,67 @@
</div>
</el-dialog>
<!-- 设备列表对话框 -->
<el-dialog :title="'账号【' + currentAccountName + '】的设备列表'" :visible.sync="deviceListVisible" width="800px" append-to-body>
<el-table :data="deviceList" v-loading="deviceListLoading">
<el-table-column label="设备名称" prop="name" :show-overflow-tooltip="true" />
<el-table-column label="操作系统" prop="os" width="120" />
<el-table-column label="状态" prop="status" width="80" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.status === 'online' ? 'success' : 'info'" size="small">
{{ scope.row.status === 'online' ? '在线' : '离线' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="设备试用期" prop="trialExpireTime" width="130" align="center">
<template slot-scope="scope">
<el-tag
:type="getRemainingDays(scope.row.trialExpireTime).type"
size="small"
>
{{ getRemainingDays(scope.row.trialExpireTime).text }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="最近在线" prop="lastActiveAt" width="160" />
<el-table-column label="操作" align="center" width="100">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="editDeviceExpire(scope.row)"
>修改</el-button>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="deviceListVisible = false"> </el-button>
</div>
</el-dialog>
<!-- 修改设备过期时间对话框 -->
<el-dialog title="修改设备试用期" :visible.sync="deviceExpireDialogVisible" width="400px" append-to-body>
<el-form label-width="120px">
<el-form-item label="设备名称">
<el-input v-model="currentDevice.name" disabled />
</el-form-item>
<el-form-item label="试用期过期时间">
<el-date-picker
v-model="currentDevice.trialExpireTime"
type="datetime"
placeholder="选择过期时间"
value-format="yyyy-MM-dd HH:mm:ss"
style="width: 100%;"
></el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitDeviceExpire"> </el-button>
<el-button @click="deviceExpireDialogVisible = false"> </el-button>
</div>
</el-dialog>
<!-- 注册对话框 -->
<el-dialog title="客户端账号注册" :visible.sync="registerOpen" width="400px" append-to-body>
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" label-width="80px">
@@ -231,7 +304,7 @@
</template>
<script>
import { listAccount, getAccount, delAccount, addAccount, updateAccount, registerAccount, checkUsername, renewAccount } from "@/api/monitor/account";
import { listAccount, getAccount, delAccount, addAccount, updateAccount, registerAccount, checkUsername, renewAccount, getDeviceList, updateDeviceExpire } from "@/api/monitor/account";
export default {
name: "Account",
@@ -262,6 +335,14 @@ export default {
registerLoading: false,
usernameChecking: false,
usernameAvailable: null,
// 设备列表
deviceListVisible: false,
deviceListLoading: false,
deviceList: [],
currentAccountName: '',
// 设备过期时间编辑
deviceExpireDialogVisible: false,
currentDevice: {},
// 状态数据字典
statusOptions: [
{ dictLabel: "正常", dictValue: "0" },
@@ -325,11 +406,6 @@ export default {
this.loading = false;
});
},
// 检查是否过期
isExpired(row) {
if (!row.expireTime) return false;
return new Date(row.expireTime) < new Date();
},
// 表单重置
reset() {
this.form = {
@@ -338,6 +414,7 @@ export default {
username: null,
password: null,
status: "0",
accountType: "trial",
expireTime: null,
renewDays: null,
deviceLimit: 3,
@@ -518,6 +595,43 @@ export default {
this.registerOpen = false;
this.resetRegisterForm();
},
/** 查看设备列表 */
async viewDevices(row) {
this.currentAccountName = row.accountName || row.username;
this.deviceListVisible = true;
this.deviceListLoading = true;
try {
const response = await getDeviceList(row.username);
this.deviceList = response.data || [];
} catch (error) {
this.$modal.msgError('获取设备列表失败');
this.deviceList = [];
} finally {
this.deviceListLoading = false;
}
},
/** 编辑设备过期时间 */
editDeviceExpire(row) {
this.currentDevice = { ...row };
this.deviceExpireDialogVisible = true;
},
/** 提交设备过期时间修改 */
async submitDeviceExpire() {
try {
await updateDeviceExpire({
deviceId: this.currentDevice.deviceId,
username: this.currentDevice.username,
trialExpireTime: this.currentDevice.trialExpireTime
});
this.$modal.msgSuccess('修改成功');
this.deviceExpireDialogVisible = false;
// 刷新设备列表
const response = await getDeviceList(this.currentDevice.username);
this.deviceList = response.data || [];
} catch (error) {
this.$modal.msgError('修改失败: ' + (error.message || '未知错误'));
}
},
/** 计算续费后的新到期时间 */
calculateNewExpireTime() {
if (!this.form.renewDays) return '';
@@ -542,13 +656,13 @@ export default {
});
},
/** 获取剩余天数 */
getRemainingDays(row) {
if (!row.expireTime) {
return { text: '已过期', type: 'danger' };
getRemainingDays(expireTime) {
if (!expireTime) {
return { text: '未设置', type: 'info' };
}
const now = new Date();
const expireDate = new Date(row.expireTime);
const expireDate = new Date(expireTime);
const diffTime = expireDate - now;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));