refactor: 完成项目目录重构与代码迁移
本次提交完成了整体项目的目录梳理与代码迁移: 1. 将根级controlplane、webhost等目录的代码迁移至desktop/对应子目录,统一桌面端架构 2. 移动并整理了插件目录结构,将插件统一放入根级plugins/ 3. 调整了前端项目的路径与配置,统一前后端开发构建流程 4. 清理了废弃的旧版app/目录与冗余的构建中间文件 5. 更新了.gitignore与README.md,适配新的项目结构
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="login">
|
||||
<div class="card">
|
||||
<div class="brand">
|
||||
<span class="logo">37</span>
|
||||
<div class="brand-meta">
|
||||
<h1>{{ appName }}</h1>
|
||||
<p>中心机统一账户登录</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<n-form class="form" label-placement="top" @keydown.enter.prevent="doLogin">
|
||||
<n-form-item label="账号">
|
||||
<n-input
|
||||
v-model:value="account"
|
||||
placeholder="请输入账号"
|
||||
autocomplete="username"
|
||||
size="large"
|
||||
@keyup.enter="doLogin"
|
||||
>
|
||||
<template #prefix><n-icon><User /></n-icon></template>
|
||||
</n-input>
|
||||
</n-form-item>
|
||||
<n-form-item label="密码">
|
||||
<n-input
|
||||
v-model:value="password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
autocomplete="current-password"
|
||||
size="large"
|
||||
show-password-on="click"
|
||||
@keyup.enter="doLogin"
|
||||
>
|
||||
<template #prefix><n-icon><Lock /></n-icon></template>
|
||||
</n-input>
|
||||
</n-form-item>
|
||||
<n-button type="primary" size="large" block class="primary" :loading="busy" @click="doLogin">
|
||||
{{ busy ? '登录中…' : '登 录' }}
|
||||
</n-button>
|
||||
</n-form>
|
||||
|
||||
<div class="foot">内网管理面 · 请使用管理员账号登录</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { User, Lock } from '@element-plus/icons-vue'
|
||||
import { adminLogin } from '../api'
|
||||
import { store } from '../store.js'
|
||||
import { message } from '../naive'
|
||||
|
||||
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
|
||||
try { localStorage.setItem('cp_account', acct); localStorage.setItem('cp_token', store.token) } catch (_) {}
|
||||
message.success(`欢迎,${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;
|
||||
background: linear-gradient(180deg, #f7f8fa 0%, #eef0f4 100%);
|
||||
font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif);
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 380px;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
border: 1px solid var(--cp-border, #e5e7ec);
|
||||
border-radius: 16px;
|
||||
padding: 34px 32px 28px;
|
||||
box-shadow: 0 16px 40px -24px rgba(30, 42, 76, .25);
|
||||
}
|
||||
|
||||
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
|
||||
.logo {
|
||||
width: 42px; height: 42px; border-radius: 12px; flex: none;
|
||||
display: grid; place-items: center;
|
||||
background: linear-gradient(135deg, #3b6cff 0%, #22c7e8 130%);
|
||||
color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .4px;
|
||||
box-shadow: 0 8px 18px -8px rgba(59, 108, 255, .55);
|
||||
}
|
||||
.brand-meta h1 { margin: 0; font-size: 17px; font-weight: 700; color: var(--cp-ink, #1c2433); letter-spacing: .2px; }
|
||||
.brand-meta p { margin: 3px 0 0; font-size: 12px; color: var(--cp-ink-3, #8a93a6); }
|
||||
|
||||
.form :deep(.n-form-item) { margin-bottom: 20px; }
|
||||
.form :deep(.n-form-item-label) { font-size: 12.5px; font-weight: 600; color: var(--cp-ink-2, #4a5270); padding-bottom: 6px; }
|
||||
.form :deep(.n-input) { border-radius: 8px; }
|
||||
.form :deep(.n-input__inner) { font-size: 14px; }
|
||||
|
||||
.primary.n-button--primary-type { height: 44px; border-radius: 8px; font-size: 14px; letter-spacing: .1em; }
|
||||
|
||||
.foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--cp-ink-3, #8a93a6); }
|
||||
</style>
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<n-modal v-model:show="visible" preset="card" title="修改密码" :style="{ width: '420px' }" :bordered="false" @after-leave="reset">
|
||||
<n-alert v-if="store.current" type="info" :bordered="false" class="acct-tip">当前账号:{{ store.current }}</n-alert>
|
||||
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||
<n-form-item label="原密码" path="oldPwd">
|
||||
<n-input v-model:value="form.oldPwd" type="password" show-password-on="click" placeholder="请输入原密码" />
|
||||
</n-form-item>
|
||||
<n-form-item label="新密码" path="newPwd">
|
||||
<n-input v-model:value="form.newPwd" type="password" show-password-on="click" placeholder="至少 6 位,不与原密码相同" />
|
||||
</n-form-item>
|
||||
<n-form-item label="确认新密码" path="newPwd2">
|
||||
<n-input v-model:value="form.newPwd2" type="password" show-password-on="click" placeholder="再次输入新密码" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button @click="visible = false">取消</n-button>
|
||||
<n-button type="primary" :loading="busy" @click="submit">保存</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import { store } from '../store'
|
||||
import { adminPassword } from '../api'
|
||||
import { message } from '../naive'
|
||||
|
||||
const visible = defineModel({ type: Boolean, default: false })
|
||||
const formRef = ref()
|
||||
const busy = ref(false)
|
||||
const form = reactive({ oldPwd: '', newPwd: '', newPwd2: '' })
|
||||
|
||||
const rules = {
|
||||
oldPwd: { required: true, message: '请输入原密码' },
|
||||
newPwd: [
|
||||
{ required: true, message: '请输入新密码' },
|
||||
{ min: 6, message: '新密码至少 6 位' },
|
||||
{ validator: (_r, v) => (v && v === form.oldPwd ? new Error('新密码不能与原密码相同') : true), message: '新密码不能与原密码相同' },
|
||||
],
|
||||
newPwd2: [
|
||||
{ required: true, message: '请再次输入新密码' },
|
||||
{ validator: (_r, v) => (v !== form.newPwd ? new Error('两次输入的密码不一致') : true), message: '两次输入的密码不一致' },
|
||||
],
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.oldPwd = form.newPwd = form.newPwd2 = ''
|
||||
formRef.value?.restoreValidation()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
try { await formRef.value.validate() } catch (_) { return }
|
||||
busy.value = true
|
||||
try {
|
||||
await adminPassword({ account: store.current, old_password: form.oldPwd, new_password: form.newPwd })
|
||||
message.success('密码已修改,下次登录请使用新密码')
|
||||
visible.value = false
|
||||
} catch (e) {
|
||||
message.error('修改失败:' + (e.message || e))
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.acct-tip { margin-bottom: 14px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user