feat: 搭建控制面管理前端并剥离底座管理功能
1. 新增controlplane/frontend Vue3管理前端,实现登录、账号CRUD、插件上传/管理、权限授权 2. 为controlplane/app.py添加CORS中间件并挂载前端静态产物 3. 重构环境变量加载,统一使用app/common/env.load_app_env() 4. 剥离webhost/的管理UI与代理接口,仅保留基础登录能力 5. 新增环境隔离规范文档与架构蓝图说明
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<div class="login-wrap">
|
||||
<div class="card panel">
|
||||
<div class="brand">
|
||||
<span class="logo">37</span>
|
||||
<div class="brand-meta">
|
||||
<strong>{{ appName }}</strong>
|
||||
<span>中心机统一账户登录</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<input v-model="account" class="input" placeholder="账号" @keyup.enter="doLogin">
|
||||
<input v-model="password" class="input" type="password" placeholder="密码" @keyup.enter="doLogin">
|
||||
</div>
|
||||
<p v-if="err" class="err">{{ err }}</p>
|
||||
<button class="btn primary" :disabled="busy" @click="doLogin">
|
||||
{{ busy ? '校验中…' : '登录' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
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)
|
||||
const err = ref('')
|
||||
|
||||
async function doLogin() {
|
||||
if (busy.value) return
|
||||
const acct = account.value.trim()
|
||||
if (!acct || !password.value) { err.value = '请输入账号与密码'; return }
|
||||
busy.value = true
|
||||
err.value = ''
|
||||
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.isAdmin = true
|
||||
try { localStorage.setItem('cp_account', acct) } catch (_) {}
|
||||
emit('ok', r)
|
||||
} catch (e) {
|
||||
err.value = e.message || String(e)
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-wrap { flex: 1; display: grid; place-items: center; }
|
||||
.card { width: 340px; padding: 28px 26px; display: flex; flex-direction: column;
|
||||
gap: 16px; box-shadow: var(--shadow-md); }
|
||||
.brand { display: flex; align-items: center; gap: 11px; }
|
||||
.logo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
|
||||
background: var(--primary-grad); color: #fff; font-size: 15px; font-weight: 800;
|
||||
box-shadow: 0 4px 14px -3px rgba(59,108,255,.6); }
|
||||
.brand-meta { display: flex; flex-direction: column; line-height: 1.3; }
|
||||
.brand-meta strong { font-size: 14px; }
|
||||
.brand-meta span { font-size: 11px; color: var(--text-faint); }
|
||||
.fields { display: flex; flex-direction: column; gap: 10px; }
|
||||
.input { width: 100%; }
|
||||
.err { color: var(--err); font-size: 12px; margin: 0; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user