- 移除了 AuthServiceImpl 中的登录、注册、token 验证等方法,仅保留错误上报和客户端信息功能 - 删除了设备注册和离线通知相关逻辑 - 移除了 IAuthService 接口中的登录、注册、验证 token 等方法定义 - 清理了 AccountManager.vue 中的无关注释文字-优化了阿里巴巴1688 服务中的图片上传处理逻辑- 移除了 AmazonScrapingServiceImpl 中未使用的日志导入和空行 - 统一了 Vue 组件中的同步导入方式,替换异步组件定义 - 更新了应用配置文件中的服务器地址和懒加载设置 - 新增缓存管理服务用于统一清理各类缓存数据 - 优化了设备 IP 地址获取逻辑并在注册时传递给后端- 调整了构建配置以减小安装包体积并支持多语言 - 修改了主进程窗口加载逻辑以适配开发与生产环境- 添加了全局样式限制图片预览器尺寸 - 移除了设备 ID 测试类和部分无用的正则表达式导入
163 lines
3.8 KiB
Vue
163 lines
3.8 KiB
Vue
<script setup lang="ts">
|
||
import { ref, computed } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { User } from '@element-plus/icons-vue'
|
||
import { authApi } from '../../api/auth'
|
||
import { getOrCreateDeviceId } from '../../utils/deviceId'
|
||
|
||
interface Props {
|
||
modelValue: boolean
|
||
}
|
||
|
||
interface Emits {
|
||
(e: 'update:modelValue', value: boolean): void
|
||
(e: 'loginSuccess', data: { token: string; permissions?: string; expireTime?: string; accountType?: string; deviceTrialExpired?: boolean }): void
|
||
(e: 'showRegister'): void
|
||
}
|
||
|
||
const props = defineProps<Props>()
|
||
const emit = defineEmits<Emits>()
|
||
|
||
const authForm = ref({ username: '', password: '' })
|
||
const authLoading = ref(false)
|
||
|
||
const visible = computed({
|
||
get: () => props.modelValue,
|
||
set: (value) => emit('update:modelValue', value)
|
||
})
|
||
|
||
async function handleAuth() {
|
||
if (!authForm.value.username || !authForm.value.password) return
|
||
|
||
authLoading.value = true
|
||
try {
|
||
// 获取或生成设备ID
|
||
const deviceId = await getOrCreateDeviceId()
|
||
|
||
// 登录
|
||
const loginRes: any = await authApi.login({
|
||
...authForm.value,
|
||
clientId: deviceId
|
||
})
|
||
|
||
emit('loginSuccess', {
|
||
token: loginRes.data.accessToken || loginRes.data.token,
|
||
permissions: loginRes.data.permissions,
|
||
expireTime: loginRes.data.expireTime,
|
||
accountType: loginRes.data.accountType,
|
||
deviceTrialExpired: loginRes.data.deviceTrialExpired || false
|
||
})
|
||
ElMessage.success('登录成功')
|
||
resetForm()
|
||
} catch (err) {
|
||
ElMessage.error((err as Error).message)
|
||
} finally {
|
||
authLoading.value = false
|
||
}
|
||
}
|
||
|
||
function cancelAuth() {
|
||
visible.value = false
|
||
resetForm()
|
||
}
|
||
|
||
function resetForm() {
|
||
authForm.value = { username: '', password: '' }
|
||
}
|
||
|
||
function showRegister() {
|
||
emit('showRegister')
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<el-dialog
|
||
title=""
|
||
v-model="visible"
|
||
:close-on-click-modal="false"
|
||
width="360px"
|
||
center
|
||
class="auth-dialog">
|
||
<div style="padding: 20px 0;">
|
||
<div style="text-align: center; margin-bottom: 16px; color: #666;">
|
||
<img src="/icon/image.png" alt="logo" class="auth-logo" />
|
||
</div>
|
||
<div class="auth-title-wrap">
|
||
<h3 class="auth-title">账号登录</h3>
|
||
<p class="auth-subtitle">登录账户以获取完整服务体验</p>
|
||
</div>
|
||
|
||
<el-input
|
||
v-model="authForm.username"
|
||
placeholder="请输入用户名"
|
||
size="large"
|
||
style="margin-bottom: 15px;"
|
||
:disabled="authLoading"
|
||
@keyup.enter="handleAuth">
|
||
</el-input>
|
||
|
||
<el-input
|
||
v-model="authForm.password"
|
||
placeholder="请输入密码"
|
||
type="password"
|
||
size="large"
|
||
style="margin-bottom: 20px;"
|
||
:disabled="authLoading"
|
||
@keyup.enter="handleAuth">
|
||
</el-input>
|
||
|
||
<div>
|
||
<el-button
|
||
type="primary"
|
||
size="large"
|
||
:loading="authLoading"
|
||
:disabled="!authForm.username || !authForm.password || authLoading"
|
||
@click="handleAuth"
|
||
style="width: 100%;">
|
||
登录
|
||
</el-button>
|
||
</div>
|
||
|
||
<div style="margin-top: 20px; text-align: center;">
|
||
<el-button type="text" @click="showRegister" :disabled="authLoading">
|
||
还没有账号?点击注册
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</el-dialog>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.auth-logo {
|
||
width: 160px;
|
||
height: auto;
|
||
}
|
||
|
||
.auth-dialog {
|
||
--el-color-primary: #1677FF;
|
||
}
|
||
|
||
.auth-dialog :deep(.el-button--primary) {
|
||
background-color: #1677FF;
|
||
border-color: #1677FF;
|
||
}
|
||
|
||
.auth-title-wrap {
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.auth-title {
|
||
margin: 0;
|
||
font-size: 18px;
|
||
font-weight: 700;
|
||
color: #1f1f1f;
|
||
text-align: left;
|
||
}
|
||
|
||
.auth-subtitle {
|
||
margin: 6px 0 0;
|
||
font-size: 12px;
|
||
color: #8c8c8c;
|
||
text-align: left;
|
||
}
|
||
</style> |