refactor(auth):重构认证服务并移除冗余代码

- 移除了 AuthServiceImpl 中的登录、注册、token 验证等方法,仅保留错误上报和客户端信息功能
- 删除了设备注册和离线通知相关逻辑
- 移除了 IAuthService 接口中的登录、注册、验证 token 等方法定义
- 清理了 AccountManager.vue 中的无关注释文字-优化了阿里巴巴1688 服务中的图片上传处理逻辑- 移除了 AmazonScrapingServiceImpl 中未使用的日志导入和空行
- 统一了 Vue 组件中的同步导入方式,替换异步组件定义
- 更新了应用配置文件中的服务器地址和懒加载设置
- 新增缓存管理服务用于统一清理各类缓存数据
- 优化了设备 IP 地址获取逻辑并在注册时传递给后端- 调整了构建配置以减小安装包体积并支持多语言
- 修改了主进程窗口加载逻辑以适配开发与生产环境- 添加了全局样式限制图片预览器尺寸
- 移除了设备 ID 测试类和部分无用的正则表达式导入
This commit is contained in:
2025-10-20 18:01:40 +08:00
parent 0c85aa5677
commit 17f03c3ade
27 changed files with 517 additions and 535 deletions

View File

@@ -20,6 +20,7 @@ interface Props {
interface Emits {
(e: 'update:modelValue', value: boolean): void
(e: 'autoUpdateChanged', value: boolean): void
(e: 'openUpdateDialog'): void
}
const props = defineProps<Props>()
@@ -50,7 +51,14 @@ const feedbackSubmitting = ref(false)
const logDates = ref<string[]>([])
// 关闭行为配置
const closeAction = ref<'quit' | 'minimize' | 'tray'>('tray')
const closeAction = ref<'quit' | 'minimize' | 'tray'>('quit')
// 缓存相关
const clearingCache = ref(false)
// 启动配置
const autoLaunch = ref(false)
const launchMinimized = ref(false)
// 更新相关
const currentVersion = ref('')
@@ -95,6 +103,12 @@ async function saveAllSettings() {
// 保存关闭行为配置
await (window as any).electronAPI.setCloseAction(closeAction.value)
// 保存启动配置
await (window as any).electronAPI.setLaunchConfig({
autoLaunch: autoLaunch.value,
launchMinimized: launchMinimized.value
})
ElMessage({ message: '设置已保存', type: 'success' })
show.value = false
@@ -123,10 +137,89 @@ function resetPlatformSettings(platform: Platform) {
}
// 重置所有设置
function resetAllSettings() {
platforms.forEach(platform => {
resetPlatformSettings(platform.key)
})
async function resetAllSettings() {
try {
await ElMessageBox.confirm(
'确定要重置所有设置吗?此操作不可恢复。',
'确认重置',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
// 重置所有平台设置
platforms.forEach(platform => {
resetPlatformSettings(platform.key)
})
// 重置自动更新配置
autoUpdate.value = false
// 重置关闭行为配置
closeAction.value = 'quit'
// 重置启动配置
autoLaunch.value = false
launchMinimized.value = false
ElMessage.success('所有设置已重置')
} catch {
// 用户取消操作
}
}
// 清理缓存
async function handleClearCache() {
try {
await ElMessageBox.confirm(
'确定要清理客户端缓存吗?将清除所有缓存数据、更新文件及相关状态(不影响登录状态)',
'确认清理',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
clearingCache.value = true
// 1. 清理后端数据库缓存
const result = await (window as any).electronAPI.clearCache()
if (!result || result.code !== 0) {
ElMessage.error('缓存清理失败')
return
}
// 2. 清除更新相关的 localStorage 状态
localStorage.removeItem('skipped_version')
localStorage.removeItem('remind_later_time')
// 3. 清除已下载的更新文件
await (window as any).electronAPI.clearUpdateFiles()
ElMessage.success('缓存清理成功')
} catch (error: any) {
if (error !== 'cancel') {
ElMessage.error('缓存清理失败')
}
} finally {
clearingCache.value = false
}
}
// 加载启动配置
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)
}
}
// 滚动到指定区域
@@ -179,7 +272,7 @@ function handleScroll() {
const container = settingsMainRef.value
if (!container) return
const sections = ['export', 'update', 'feedback', 'general']
const sections = ['export', 'update', 'cache', 'startup', 'feedback', 'general']
const scrollTop = container.scrollTop
const containerHeight = container.clientHeight
const scrollHeight = container.scrollHeight
@@ -249,6 +342,12 @@ async function checkForUpdates() {
}
}
// 处理立即升级按钮点击
function handleUpgradeClick() {
show.value = false
emit('openUpdateDialog')
}
// 加载当前版本
async function loadCurrentVersion() {
try {
@@ -315,6 +414,7 @@ onMounted(() => {
loadLogDates()
loadCloseAction()
loadCurrentVersion()
loadLaunchConfig()
})
</script>
@@ -339,6 +439,18 @@ onMounted(() => {
<span class="sidebar-icon">🔄</span>
<span class="sidebar-text">更新</span>
</div>
<div
:class="['sidebar-item', { active: activeTab === 'cache' }]"
@click="scrollToSection('cache')">
<span class="sidebar-icon">💾</span>
<span class="sidebar-text">缓存</span>
</div>
<div
:class="['sidebar-item', { active: activeTab === 'startup' }]"
@click="scrollToSection('startup')">
<span class="sidebar-icon">🚀</span>
<span class="sidebar-text">启动</span>
</div>
<div
:class="['sidebar-item', { active: activeTab === 'feedback' }]"
@click="scrollToSection('feedback')">
@@ -409,7 +521,7 @@ onMounted(() => {
type="primary"
size="small"
:loading="checkingUpdate"
@click="checkForUpdates">
@click="hasUpdate ? handleUpgradeClick() : checkForUpdates()">
{{ checkingUpdate ? '检查中...' : (hasUpdate ? '立即升级' : '检查更新') }}
</el-button>
</div>
@@ -435,6 +547,46 @@ onMounted(() => {
</div>
</div>
<!-- 缓存设置 -->
<div id="section-cache" class="setting-section" @mouseenter="activeTab = 'cache'">
<div class="section-title">缓存设置</div>
<div class="setting-item">
<div class="setting-row">
<span class="cache-desc">清理应用缓存数据不影响登录状态</span>
<el-button
type="primary"
size="small"
:loading="clearingCache"
:disabled="clearingCache"
@click="handleClearCache">
{{ clearingCache ? '清理中' : '清理缓存' }}
</el-button>
</div>
</div>
</div>
<!-- 启动设置 -->
<div id="section-startup" class="setting-section" @mouseenter="activeTab = 'startup'">
<div class="section-title">启动</div>
<div class="setting-item">
<div class="checkbox-row">
<el-checkbox v-model="autoLaunch" size="default">
开机时自动启动
</el-checkbox>
</div>
</div>
<div class="setting-item" style="margin-top: 10px;">
<div class="checkbox-row">
<el-checkbox v-model="launchMinimized" size="default">
启动后最小化到程序坞
</el-checkbox>
</div>
</div>
</div>
<!-- 反馈页面 -->
<div id="section-feedback" class="setting-section" @mouseenter="activeTab = 'feedback'">
<div class="section-title">反馈</div>
@@ -726,6 +878,11 @@ onMounted(() => {
text-align: left;
}
.cache-desc {
font-size: 13px;
color: #86909C;
}
.setting-item {
margin-bottom: 0;
}