feat(client): 实现用户数据隔离与设备绑定优化- 添加用户会话ID构建逻辑,确保数据按用户隔离- 优化设备绑定流程,支持设备状态更新和绑定时间同步- 实现用户缓存清理功能,仅清除当前用户的数据- 增强客户端账号删除逻辑,级联删除相关数据
- 调整设备在线查询逻辑,确保只返回活跃绑定的设备 - 优化试用期逻辑,精确计算过期时间和类型- 添加账号管理弹窗和相关状态注入 -修复跟卖精灵按钮加载状态显示问题 - 增强文件上传区域UI,显示选中文件名 - 调整分页组件样式,优化界面展示效果- 优化反馈日志存储路径逻辑,默认使用用户目录 - 移除冗余代码和无用导入,提升代码整洁度
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { ref, computed, onMounted, watch, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
getSettings,
|
||||
@@ -73,6 +73,14 @@ const show = computed({
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
// 监听对话框打开,重新加载当前用户的设置
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
if (newVal) {
|
||||
loadAllSettings()
|
||||
loadCurrentVersion()
|
||||
}
|
||||
})
|
||||
|
||||
// 选择导出路径
|
||||
async function selectExportPath(platform: Platform) {
|
||||
const result = await (window as any).electronAPI.showOpenDialog({
|
||||
@@ -88,22 +96,21 @@ async function selectExportPath(platform: Platform) {
|
||||
|
||||
// 保存设置
|
||||
async function saveAllSettings() {
|
||||
Object.keys(platformSettings.value).forEach(platformKey => {
|
||||
const platform = platformKey as Platform
|
||||
const platformConfig = platformSettings.value[platform]
|
||||
savePlatformSettings(platform, platformConfig)
|
||||
})
|
||||
|
||||
// 保存自动更新配置
|
||||
const oldSettings = getSettings()
|
||||
const username = getUsernameFromToken()
|
||||
const oldSettings = getSettings(username)
|
||||
const autoUpdateChanged = oldSettings.autoUpdate !== autoUpdate.value
|
||||
|
||||
saveSettings({ autoUpdate: autoUpdate.value })
|
||||
// 1. 保存到 localStorage(按账号隔离)
|
||||
saveSettings({
|
||||
platforms: platformSettings.value,
|
||||
autoUpdate: autoUpdate.value,
|
||||
closeAction: closeAction.value,
|
||||
autoLaunch: autoLaunch.value,
|
||||
launchMinimized: launchMinimized.value
|
||||
}, username)
|
||||
|
||||
// 保存关闭行为配置
|
||||
// 2. 同步到 Electron 主进程(控制应用行为)
|
||||
await (window as any).electronAPI.setCloseAction(closeAction.value)
|
||||
|
||||
// 保存启动配置
|
||||
await (window as any).electronAPI.setLaunchConfig({
|
||||
autoLaunch: autoLaunch.value,
|
||||
launchMinimized: launchMinimized.value
|
||||
@@ -112,7 +119,6 @@ async function saveAllSettings() {
|
||||
ElMessage({ message: '设置已保存', type: 'success' })
|
||||
show.value = false
|
||||
|
||||
// 如果自动更新配置改变了,通知父组件
|
||||
if (autoUpdateChanged) {
|
||||
emit('autoUpdateChanged', autoUpdate.value)
|
||||
}
|
||||
@@ -120,13 +126,17 @@ async function saveAllSettings() {
|
||||
|
||||
// 加载设置
|
||||
function loadAllSettings() {
|
||||
const settings = getSettings()
|
||||
const username = getUsernameFromToken()
|
||||
const settings = getSettings(username)
|
||||
platformSettings.value = {
|
||||
amazon: { ...settings.platforms.amazon },
|
||||
rakuten: { ...settings.platforms.rakuten },
|
||||
zebra: { ...settings.platforms.zebra }
|
||||
}
|
||||
autoUpdate.value = settings.autoUpdate ?? false
|
||||
closeAction.value = settings.closeAction ?? 'quit'
|
||||
autoLaunch.value = settings.autoLaunch ?? false
|
||||
launchMinimized.value = settings.launchMinimized ?? false
|
||||
}
|
||||
|
||||
// 重置单个平台设置
|
||||
@@ -149,20 +159,15 @@ async function resetAllSettings() {
|
||||
}
|
||||
)
|
||||
|
||||
// 重置所有平台设置
|
||||
platforms.forEach(platform => {
|
||||
resetPlatformSettings(platform.key)
|
||||
})
|
||||
|
||||
// 重置自动更新配置
|
||||
autoUpdate.value = false
|
||||
|
||||
// 重置关闭行为配置
|
||||
closeAction.value = 'quit'
|
||||
|
||||
// 重置启动配置
|
||||
autoLaunch.value = false
|
||||
launchMinimized.value = false
|
||||
|
||||
ElMessage.success('所有设置已重置')
|
||||
} catch {
|
||||
// 用户取消操作
|
||||
@@ -208,19 +213,6 @@ async function handleClearCache() {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载启动配置
|
||||
async function loadLaunchConfig() {
|
||||
try {
|
||||
const config = await (window as any).electronAPI.getLaunchConfig()
|
||||
if (config) {
|
||||
autoLaunch.value = config.autoLaunch || false
|
||||
launchMinimized.value = config.launchMinimized || false
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('获取启动配置失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 滚动到指定区域
|
||||
function scrollToSection(sectionKey: string) {
|
||||
if (isScrolling.value) return
|
||||
@@ -277,16 +269,6 @@ async function loadLogDates() {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载关闭行为配置
|
||||
async function loadCloseAction() {
|
||||
try {
|
||||
const action = await (window as any).electronAPI.getCloseAction()
|
||||
if (action) closeAction.value = action
|
||||
} catch (error) {
|
||||
console.warn('获取关闭行为配置失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查更新
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
@@ -382,9 +364,7 @@ async function submitFeedback() {
|
||||
onMounted(() => {
|
||||
loadAllSettings()
|
||||
loadLogDates()
|
||||
loadCloseAction()
|
||||
loadCurrentVersion()
|
||||
loadLaunchConfig()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user