1. 移除naive-ui依赖,迁移前端至Element Plus 2. 重构后端数据库层,切换为MySQL替代SQLite 3. 调整项目部署架构,停止exe打包改为源码部署 4. 新增设备上报接口与相关数据库模型 5. 优化配置路径与SQL语法,替换为MySQL占位符格式 6. 调整站点名称与文案,统一为「37du 插件管理平台」 7. 新增SQLite到MySQL迁移脚本
185 lines
4.5 KiB
Vue
185 lines
4.5 KiB
Vue
<template>
|
|
<div class="login">
|
|
<div class="card cp-rise">
|
|
<div class="brand">
|
|
<span class="logo">37</span>
|
|
<div class="brand-meta">
|
|
<h1>{{ appName }}</h1>
|
|
<p>中心机统一账户登录</p>
|
|
</div>
|
|
</div>
|
|
|
|
<el-form class="form" label-position="top" @keyup.enter="doLogin">
|
|
<el-form-item label="账号">
|
|
<el-input v-model="account" placeholder="请输入账号" autocomplete="username" size="large"
|
|
:prefix-icon="User" @keyup.enter="doLogin" />
|
|
</el-form-item>
|
|
<el-form-item label="密码">
|
|
<el-input v-model="password" type="password" placeholder="请输入密码" autocomplete="current-password"
|
|
size="large" :prefix-icon="Lock" show-password @keyup.enter="doLogin" />
|
|
</el-form-item>
|
|
<el-button type="primary" size="large" class="primary" :loading="busy" @click="doLogin">
|
|
{{ busy ? '登录中…' : '登 录' }}
|
|
</el-button>
|
|
</el-form>
|
|
|
|
<div class="foot">内网管理面 · 请使用管理员账号登录</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import { User, Lock } from '@element-plus/icons-vue'
|
|
import { ElMessage as message } from 'element-plus'
|
|
import { adminLogin } from '../api'
|
|
import { store } from '../store.js'
|
|
|
|
const props = defineProps({ appName: { type: String, default: '37du 自动化工作台' } })
|
|
const emit = defineEmits(['ok'])
|
|
|
|
const account = ref('')
|
|
const password = ref('')
|
|
const busy = ref(false)
|
|
|
|
async function doLogin() {
|
|
if (busy.value) return
|
|
const acct = account.value.trim()
|
|
if (!acct || !password.value) { message.warning('请输入账号与密码'); return }
|
|
busy.value = true
|
|
try {
|
|
const r = await adminLogin(acct, password.value)
|
|
if (!r.ok) throw new Error('登录失败')
|
|
if (!r.is_admin) { throw new Error('该账号无管理权限') }
|
|
store.current = acct
|
|
store.token = r.token || ''
|
|
store.isAdmin = true
|
|
store.nickname = r.nickname || ''
|
|
try { localStorage.setItem('cp_account', acct); localStorage.setItem('cp_token', store.token) } catch (_) { }
|
|
message.success(`欢迎,${store.nickname || acct}`)
|
|
emit('ok', r)
|
|
} catch (e) {
|
|
message.error(e.message || String(e))
|
|
} finally {
|
|
busy.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.login {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 24px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.card {
|
|
width: 404px;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
background: var(--cp-panel);
|
|
border: 1px solid var(--cp-line);
|
|
border-radius: 22px;
|
|
padding: 40px 36px 28px;
|
|
box-shadow: 0 26px 64px -30px rgba(35, 42, 58, .45);
|
|
}
|
|
|
|
/* 顶部渐变描边 */
|
|
.card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 30px;
|
|
right: 30px;
|
|
height: 2px;
|
|
background: linear-gradient(90deg, transparent, var(--cp-blue), var(--cp-teal), transparent);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
/* 纸面噪点质感 */
|
|
.card::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 0;
|
|
border-radius: 22px;
|
|
pointer-events: none;
|
|
opacity: .5;
|
|
background-image: radial-gradient(rgba(35, 42, 58, .08) 0.5px, transparent 0.5px);
|
|
background-size: 5px 5px;
|
|
}
|
|
|
|
.brand {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14px;
|
|
margin-bottom: 30px;
|
|
position: relative;
|
|
}
|
|
|
|
.logo {
|
|
width: 46px;
|
|
height: 46px;
|
|
border-radius: 14px;
|
|
flex: none;
|
|
display: grid;
|
|
place-items: center;
|
|
position: relative;
|
|
background: linear-gradient(135deg, var(--cp-blue) 0%, var(--cp-teal) 140%);
|
|
color: #fff;
|
|
font-size: 15px;
|
|
font-weight: 800;
|
|
letter-spacing: .4px;
|
|
box-shadow: 0 10px 22px -10px rgba(47, 92, 240, .6);
|
|
}
|
|
|
|
.logo::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 2px;
|
|
border-radius: 12px;
|
|
border: 1px solid rgba(255, 255, 255, .3);
|
|
}
|
|
|
|
.brand-meta h1 {
|
|
margin: 0;
|
|
font-size: 17px;
|
|
font-weight: 800;
|
|
color: var(--cp-ink-1);
|
|
letter-spacing: .2px;
|
|
}
|
|
|
|
.brand-meta p {
|
|
margin: 4px 0 0;
|
|
font-size: 12px;
|
|
color: var(--cp-ink-3);
|
|
letter-spacing: .4px;
|
|
}
|
|
|
|
.form { position: relative; }
|
|
.form .el-form-item { margin-bottom: 20px; }
|
|
.form .el-form-item__label { font-size: 12.5px; font-weight: 700; padding-bottom: 6px; }
|
|
.form .el-input__wrapper { border-radius: 10px; }
|
|
|
|
.primary {
|
|
width: 100%;
|
|
height: 46px;
|
|
border-radius: 12px;
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
letter-spacing: .12em;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.foot {
|
|
margin-top: 24px;
|
|
text-align: center;
|
|
font-size: 11.5px;
|
|
color: var(--cp-ink-3);
|
|
letter-spacing: .4px;
|
|
position: relative;
|
|
}
|
|
</style>
|