feat(frontend): 重构登录页面并新增插件强制更新功能

- 替换登录页面为极光背景玻璃拟态设计,移除注册/忘记密码页面
- 新增插件强制更新功能,支持设置最低版本和截止时间
- 修复通知账号选择占位文本和拉取失败注释
- 新增审计日志系统用户相关操作类型
- 新增用户菜单头像 fallback 逻辑
- 重构 XQ0037 工作簿写入逻辑,改用 openpyxl 直写避免时区问题
- 更新 XQ0034 脚本参数默认值和注释
This commit is contained in:
2026-10-16 11:40:43 +08:00
parent 60c28fe507
commit 2d53f643a4
21 changed files with 1145 additions and 1476 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 32 KiB

@@ -1,7 +1,7 @@
<!-- 系统logo -->
<template>
<div class="flex-cc">
<img :style="logoStyle" src="@imgs/common/logo.webp" alt="logo" class="w-full h-full" />
<img :style="logoStyle" src="@imgs/common/logo.png" alt="logo" class="w-full h-full" />
</div>
</template>
@@ -14,8 +14,9 @@
<template #reference>
<img
class="size-8.5 mr-5 c-p rounded-full max-sm:w-6.5 max-sm:h-6.5 max-sm:mr-[16px]"
src="@imgs/user/avatar.webp"
:src="avatarUrl"
alt="avatar"
@error="avatarError = true"
/>
</template>
<template #default>
@@ -23,13 +24,15 @@
<div class="flex-c pb-1 px-0">
<img
class="w-10 h-10 mr-3 ml-0 overflow-hidden rounded-full float-left"
src="@imgs/user/avatar.webp"
:src="avatarUrl"
/>
<div class="w-[calc(100%-60px)] h-full">
<span class="block text-sm font-medium text-g-800 truncate">{{
userInfo.userName
}}</span>
<span class="block mt-0.5 text-xs text-g-500 truncate">{{ userInfo.email }}</span>
<span class="block mt-0.5 text-xs text-g-500 truncate">
{{ userInfo.account || '—' }} · {{ userInfo.dept || '—' }}
</span>
</div>
</div>
<ul class="py-4 mt-3 border-t border-g-300/80">
@@ -57,6 +60,7 @@
import { ElMessageBox } from 'element-plus'
import { useUserStore } from '@/store/modules/user'
import { mittBus } from '@/utils/sys'
import defaultAvatar from '@imgs/user/avatar.webp'
defineOptions({ name: 'ArtUserMenu' })
@@ -67,6 +71,24 @@
const { getUserInfo: userInfo } = storeToRefs(userStore)
const userMenuPopover = ref()
// 真实头像(个人中心上传后回显;加载失败/未设置回退默认头像)
const avatarError = ref(false)
const avatarVersion = ref(Date.now())
const avatarUrl = computed(() => {
const acct = String(userInfo.value?.account || '')
if (!acct || avatarError.value || !userInfo.value?.avatar) {
return defaultAvatar
}
return `/api/avatar/${encodeURIComponent(acct)}?v=${avatarVersion.value}`
})
watch(
() => userInfo.value?.avatar,
() => {
avatarError.value = false
avatarVersion.value = Date.now()
}
)
/**
* 页面跳转
* @param {string} path - 目标路径
@@ -1,602 +0,0 @@
<!-- 登录、注册、忘记密码左侧背景 -->
<template>
<div class="login-left-view">
<div class="logo">
<ArtLogo class="icon" size="46" />
<h1 class="title">{{ AppConfig.systemInfo.name }}</h1>
</div>
<div class="left-img">
<ThemeSvg :src="loginIcon" size="100%" />
</div>
<div class="text-wrap">
<h1> {{ $t('login.leftView.title') }} </h1>
<p> {{ $t('login.leftView.subTitle') }} </p>
</div>
<!-- 几何装饰元素 -->
<div class="geometric-decorations">
<!-- 基础几何形状 -->
<div class="geo-element circle-outline animate-fade-in-up" style="animation-delay: 0s"></div>
<div
class="geo-element square-rotated animate-fade-in-left"
style="animation-delay: 0s"
></div>
<div class="geo-element circle-small animate-fade-in-up" style="animation-delay: 0.3s"></div>
<div
class="geo-element square-bottom-right animate-fade-in-right"
style="animation-delay: 0s"
></div>
<!-- 背景泡泡 -->
<div class="geo-element bg-bubble animate-scale-in" style="animation-delay: 0.5"></div>
<!-- 太阳/月亮 -->
<div
class="geo-element circle-top-right animate-fade-in-down"
style="animation-delay: 0.5"
@click="themeAnimation"
></div>
<!-- 装饰点 -->
<div class="geo-element dot dot-top-left animate-bounce-in" style="animation-delay: 0s"></div>
<div
class="geo-element dot dot-top-right animate-bounce-in"
style="animation-delay: 0s"
></div>
<div
class="geo-element dot dot-center-right animate-bounce-in"
style="animation-delay: 0s"
></div>
<!-- 叠加方块组 -->
<div class="squares-group">
<i
class="geo-element square square-blue animate-fade-in-left-rotated-blue"
style="animation-delay: 0.2s"
></i>
<i
class="geo-element square square-pink animate-fade-in-left-rotated-pink"
style="animation-delay: 0.4s"
></i>
<i
class="geo-element square square-purple animate-fade-in-left-no-rotation"
style="animation-delay: 0.6s"
></i>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import AppConfig from '@/config'
import loginIcon from '@imgs/svg/login_icon.svg'
import { themeAnimation } from '@/utils/ui/animation'
// 定义 props
defineProps<{
hideContent?: boolean // 是否隐藏内容,只显示 logo
}>()
</script>
<style lang="scss" scoped>
// 颜色变量定义
$primary-light-7: var(--el-color-primary-light-7);
$primary-light-8: var(--el-color-primary-light-8);
$primary-light-9: var(--el-color-primary-light-9);
$primary-base: var(--el-color-primary);
$main-bg: var(--default-box-color);
// 混合颜色函数
$bg-mix-light-9: color-mix(in srgb, $primary-light-9 100%, $main-bg);
$bg-mix-light-8: color-mix(in srgb, $primary-light-8 80%, $main-bg);
$bg-mix-light-7: color-mix(in srgb, $primary-light-7 80%, $main-bg);
.login-left-view {
position: relative;
box-sizing: border-box;
width: 65vw;
height: 100%;
padding: 15px;
overflow: hidden;
background-color: $bg-mix-light-9;
.logo {
position: relative;
z-index: 100;
display: flex;
align-items: center;
.title {
margin-left: 10px;
font-size: 20px;
font-weight: 400;
}
}
.left-img {
position: absolute;
inset: 0 0 10.5%;
z-index: 10;
width: 40%;
margin: auto;
animation: slideInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.text-wrap {
position: absolute;
bottom: 80px;
width: 100%;
text-align: center;
animation: slideInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
h1 {
font-size: 24px;
font-weight: 400;
color: var(--art-gray-900) !important;
}
p {
margin-top: 10px;
font-size: 14px;
color: var(--art-gray-600) !important;
}
}
.geometric-decorations {
.geo-element {
position: absolute;
opacity: 0;
animation-fill-mode: forwards;
animation-duration: 0.8s;
animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
// 动画 mixin
@mixin fadeAnimation($direction: '', $rotation: 0deg) {
from {
opacity: 0;
@if $direction == 'up' {
transform: translateY(30px) rotate($rotation);
} @else if $direction == 'down' {
transform: translateY(-30px) rotate($rotation);
} @else if $direction == 'left' {
transform: translateX(-30px) rotate($rotation);
} @else if $direction == 'right' {
transform: translateX(30px) rotate($rotation);
}
}
to {
opacity: 1;
@if $direction == 'up' or $direction == 'down' {
transform: translateY(0) rotate($rotation);
} @else {
transform: translateX(0) rotate($rotation);
}
}
}
// 动画定义
@keyframes fadeInUp {
@include fadeAnimation('up');
}
@keyframes fadeInDown {
@include fadeAnimation('down');
}
@keyframes fadeInLeft {
@include fadeAnimation('left');
}
@keyframes fadeInLeftRotated {
@include fadeAnimation('left', -25deg);
}
@keyframes fadeInRight {
@include fadeAnimation('right');
}
@keyframes fadeInRightRotated {
@include fadeAnimation('right', 45deg);
}
@keyframes fadeInLeftRotatedBlue {
@include fadeAnimation('left', -10deg);
}
@keyframes fadeInLeftRotatedPink {
@include fadeAnimation('left', 10deg);
}
@keyframes fadeInLeftNoRotation {
@include fadeAnimation('left');
}
@keyframes scaleIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(0.3);
}
50% {
opacity: 1;
transform: scale(1.05);
}
70% {
transform: scale(0.9);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes lineGrow {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideInLeft {
from {
opacity: 0;
transform: translateX(-30px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
// 动画类
.animate-fade-in-up {
animation-name: fadeInUp;
}
.animate-fade-in-down {
animation-name: fadeInDown;
}
.animate-fade-in-left {
animation-name: fadeInLeft;
}
.animate-fade-in-right {
animation-name: fadeInRight;
}
.animate-scale-in {
animation-name: scaleIn;
animation-duration: 1.2s;
}
.animate-bounce-in {
animation-name: bounceIn;
animation-duration: 0.6s;
}
.animate-fade-in-left-rotated-blue {
animation-name: fadeInLeftRotatedBlue;
}
.animate-fade-in-left-rotated-pink {
animation-name: fadeInLeftRotatedPink;
}
.animate-fade-in-left-no-rotation {
animation-name: fadeInLeftNoRotation;
}
// 基础几何形状
.circle-outline {
top: 10%;
left: 25%;
width: 42px;
height: 42px;
border: 2px solid $primary-light-8;
border-radius: 50%;
}
.square-rotated {
top: 50%;
left: 16%;
width: 60px;
height: 60px;
background-color: $bg-mix-light-8;
&.animate-fade-in-left {
animation-name: fadeInLeftRotated;
}
}
.circle-small {
bottom: 26%;
left: 30%;
width: 18px;
height: 18px;
background-color: $primary-light-8;
border-radius: 50%;
}
// 太阳/月亮效果
.circle-top-right {
top: 3%;
right: 3%;
z-index: 100;
width: 50px;
height: 50px;
cursor: pointer;
background: $bg-mix-light-7;
border-radius: 50%;
transition: all 0.3s;
&::after {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
content: '';
background: linear-gradient(to right, #fcbb04, #fffc00);
border-radius: 50%;
opacity: 0;
transition: all 0.5s;
transform: translate(-50%, -50%);
}
&:hover {
box-shadow: 0 0 36px #fffc00;
&::after {
opacity: 1;
}
}
}
.square-bottom-right {
right: 10%;
bottom: 10%;
width: 50px;
height: 50px;
background-color: $primary-light-8;
&.animate-fade-in-right {
animation-name: fadeInRightRotated;
}
}
// 背景泡泡
.bg-bubble {
top: -120px;
right: -120px;
width: 360px;
height: 360px;
background-color: $bg-mix-light-8;
border-radius: 50%;
}
// 装饰点
.dot {
width: 14px;
height: 14px;
background-color: $primary-light-7;
border-radius: 50%;
&.dot-top-left {
top: 140px;
left: 100px;
}
&.dot-top-right {
top: 140px;
right: 120px;
}
&.dot-center-right {
top: 46%;
right: 22%;
background-color: $primary-light-8;
}
}
// 叠加方块组
.squares-group {
position: absolute;
bottom: 18px;
left: 20px;
width: 140px;
height: 140px;
pointer-events: none;
.square {
position: absolute;
display: block;
border-radius: 8px;
box-shadow: 0 8px 24px rgb(64 87 167 / 12%);
&.square-blue {
top: 12px;
left: 30px;
z-index: 2;
width: 50px;
height: 50px;
background-color: rgb(from $primary-base r g b / 30%);
}
&.square-pink {
top: 30px;
left: 48px;
z-index: 1;
width: 70px;
height: 70px;
background-color: rgb(from $primary-base r g b / 15%);
}
&.square-purple {
top: 66px;
left: 86px;
z-index: 3;
width: 32px;
height: 32px;
background-color: rgb(from $primary-base r g b / 45%);
}
}
// 装饰线条
&::after {
position: absolute;
top: 86px;
left: 72px;
width: 80px;
height: 1px;
content: '';
background: linear-gradient(90deg, var(--el-color-primary-light-6), transparent);
opacity: 0;
transform: rotate(50deg);
animation: lineGrow 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
animation-delay: 1.2s;
}
}
}
@media only screen and (width <= 1600px) {
width: 60vw;
.text-wrap {
bottom: 40px;
}
}
@media only screen and (width <= 1180px) {
width: auto;
height: auto;
padding: 0;
// 隐藏背景和其他内容,只保留 logo
background: transparent;
.left-img,
.text-wrap,
.geometric-decorations {
display: none;
}
.logo {
display: none;
}
}
}
// 暗色主题
.dark .login-left-view {
background-color: color-mix(in srgb, $primary-light-9 60%, #070707);
@media only screen and (width <= 1180px) {
background: transparent;
}
.geometric-decorations {
// 月亮效果
.circle-top-right {
background-color: $bg-mix-light-8;
box-shadow: 0 0 25px #333 inset;
transition: all 0.3s ease-in-out 0.1s;
rotate: -48deg;
&::before {
position: absolute;
top: 0;
left: 15px;
width: 50px;
height: 50px;
content: '';
background-color: $bg-mix-light-9;
border-radius: 50%;
transition: all 0.3s ease-in-out;
}
&:hover {
background-color: transparent;
box-shadow: 0 40px 25px #ddd inset;
&::before {
left: 18px;
}
&::after {
opacity: 0;
}
}
}
.bg-bubble {
background-color: $bg-mix-light-9;
}
// 其他元素颜色调整
.square-rotated {
background-color: $bg-mix-light-9;
}
.circle-small,
.dot {
background-color: $primary-light-8;
}
.square-bottom-right {
background-color: $primary-light-9;
}
.dot.dot-top-right {
background-color: $primary-light-8;
}
}
// 方块组暗色调整
.squares-group {
.square {
box-shadow: none;
&.square-blue {
background-color: rgb(from $primary-base r g b / 18%);
}
&.square-pink {
background-color: rgb(from $primary-base r g b / 10%);
}
&.square-purple {
background-color: rgb(from $primary-base r g b / 20%);
}
}
&::after {
background: linear-gradient(90deg, $primary-light-8, transparent);
}
}
}
</style>
@@ -24,18 +24,6 @@ export const staticRoutes: AppRouteRecordRaw[] = [
component: () => import('@views/auth/login/index.vue'),
meta: { title: 'menus.login.title', isHideTab: true }
},
{
path: '/auth/register',
name: 'Register',
component: () => import('@views/auth/register/index.vue'),
meta: { title: 'menus.register.title', isHideTab: true }
},
{
path: '/auth/forget-password',
name: 'ForgetPassword',
component: () => import('@views/auth/forget-password/index.vue'),
meta: { title: 'menus.forgetPassword.title', isHideTab: true }
},
{
path: '/403',
name: 'Exception403',
@@ -1,204 +1,204 @@
<script setup lang="ts">
/**
* 账号管理(37du 控制台)
* 列表/搜索/新建/编辑/重置密码/删除,对接 /api/admin/accounts*
*/
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
fetchAccounts, createAccount, updateAccount, resetAccountPwd, deleteAccount
} from '@/api/business'
const loading = ref(false)
const list = ref<any[]>([])
const total = ref(0)
const query = reactive({ page: 1, page_size: 10, q: '' })
async function load() {
loading.value = true
try {
const r = await fetchAccounts(query)
list.value = r.items || []
total.value = r.total || 0
} finally {
loading.value = false
}
}
function search() {
query.page = 1
load()
}
// ---- 新建/编辑 ----
const dialogOpen = ref(false)
const isEdit = ref(false)
const saving = ref(false)
const form = reactive({ account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
function openCreate() {
isEdit.value = false
Object.assign(form, { account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
dialogOpen.value = true
}
function openEdit(row: any) {
isEdit.value = true
Object.assign(form, {
account: row.account, password: '', dept: row.dept || '', nickname: row.nickname || '',
is_admin: !!row.is_admin, status: row.status
})
dialogOpen.value = true
}
async function submit() {
if (!form.account) return ElMessage.warning('account 必填')
if (!isEdit.value && (!form.password || form.password.length < 8)) {
return ElMessage.warning('密码至少 8 位')
}
saving.value = true
try {
if (isEdit.value) {
await updateAccount({ account: form.account, dept: form.dept, nickname: form.nickname, is_admin: form.is_admin, status: form.status })
} else {
await createAccount(form)
}
ElMessage.success('保存成功')
dialogOpen.value = false
load()
} finally {
saving.value = false
}
}
// ---- 重置密码 ----
const pwdOpen = ref(false)
const pwdForm = reactive({ account: '', new_password: '' })
function openReset(row: any) {
Object.assign(pwdForm, { account: row.account, new_password: '' })
pwdOpen.value = true
}
async function submitReset() {
if (!pwdForm.new_password || pwdForm.new_password.length < 8) {
return ElMessage.warning('新密码至少 8 位')
}
await resetAccountPwd({ account: pwdForm.account, new_password: pwdForm.new_password })
ElMessage.success('密码已重置')
pwdOpen.value = false
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除账号「${row.account}」?`, '删除确认', { type: 'warning' })
await deleteAccount(row.account)
ElMessage.success('已删除')
load()
}
onMounted(load)
</script>
<template>
<div class="p-5 space-y-4">
<ArtPageHeader title="账号管理" description="统一账号维护、管理员标识与授权概览">
<template #actions>
<el-button type="primary" @click="openCreate"><ArtSvgIcon icon="ri:add-line" class="mr-1" />新建账号</el-button>
</template>
</ArtPageHeader>
<el-card shadow="never" class="rounded-xl">
<el-form inline @submit.prevent="search">
<el-form-item label="关键字">
<el-input v-model="query.q" placeholder="账号 / 昵称 / 部门" clearable style="width: 240px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
<el-button @click="Object.assign(query, { q: '' }); search()">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card shadow="never" class="rounded-xl">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column prop="account" label="账号" min-width="120" />
<el-table-column prop="nickname" label="昵称" min-width="120" />
<el-table-column prop="dept" label="部门" width="120" />
<el-table-column label="管理员" width="90">
<template #default="{ row }">
<el-tag v-if="row.is_admin" size="small" type="primary">管理员</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="90">
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'danger'" size="small">
{{ row.status === 1 ? '启用' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="插件授权" width="110">
<template #default="{ row }">
<el-tag v-if="row.plugins?.length" size="small" type="info">{{ row.plugins.length }} 个</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="170" />
<el-table-column label="操作" width="220" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="warning" @click="openReset(row)">重置密码</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<el-pagination
v-model:current-page="query.page"
v-model:page-size="query.page_size"
:total="total"
layout="total, prev, pager, next"
@current-change="load"
/>
</div>
</el-card>
<!-- 新建/编辑弹窗 -->
<el-dialog v-model="dialogOpen" :title="isEdit ? '编辑账号' : '新建账号'" width="480px">
<el-form label-width="90px">
<el-form-item label="账号" required>
<el-input v-model="form.account" :disabled="isEdit" placeholder="工号" />
</el-form-item>
<el-form-item v-if="!isEdit" label="初始密码" required>
<el-input v-model="form.password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="form.nickname" />
</el-form-item>
<el-form-item label="部门">
<el-input v-model="form.dept" />
</el-form-item>
<el-form-item label="管理员">
<el-switch v-model="form.is_admin" />
</el-form-item>
<el-form-item v-if="isEdit" label="状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="停用" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogOpen = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
</template>
</el-dialog>
<!-- 重置密码弹窗 -->
<el-dialog v-model="pwdOpen" title="重置密码" width="420px">
<el-form label-width="90px">
<el-form-item label="账号">{{ pwdForm.account }}</el-form-item>
<el-form-item label="新密码" required>
<el-input v-model="pwdForm.new_password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="pwdOpen = false">取消</el-button>
<el-button type="primary" @click="submitReset">重置</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
/**
* 账号管理(37du 控制台)
* 列表/搜索/新建/编辑/重置密码/删除,对接 /api/admin/accounts*
*/
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
fetchAccounts, createAccount, updateAccount, resetAccountPwd, deleteAccount
} from '@/api/business'
const loading = ref(false)
const list = ref<any[]>([])
const total = ref(0)
const query = reactive({ page: 1, page_size: 10, q: '' })
async function load() {
loading.value = true
try {
const r = await fetchAccounts(query)
list.value = r.items || []
total.value = r.total || 0
} finally {
loading.value = false
}
}
function search() {
query.page = 1
load()
}
// ---- 新建/编辑 ----
const dialogOpen = ref(false)
const isEdit = ref(false)
const saving = ref(false)
const form = reactive({ account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
function openCreate() {
isEdit.value = false
Object.assign(form, { account: '', password: '', dept: '', nickname: '', is_admin: false, status: 1 })
dialogOpen.value = true
}
function openEdit(row: any) {
isEdit.value = true
Object.assign(form, {
account: row.account, password: '', dept: row.dept || '', nickname: row.nickname || '',
is_admin: !!row.is_admin, status: row.status
})
dialogOpen.value = true
}
async function submit() {
if (!form.account) return ElMessage.warning('account 必填')
if (!isEdit.value && (!form.password || form.password.length < 8)) {
return ElMessage.warning('密码至少 8 位')
}
saving.value = true
try {
if (isEdit.value) {
await updateAccount({ account: form.account, dept: form.dept, nickname: form.nickname, is_admin: form.is_admin, status: form.status })
} else {
await createAccount(form)
}
ElMessage.success('保存成功')
dialogOpen.value = false
load()
} finally {
saving.value = false
}
}
// ---- 重置密码 ----
const pwdOpen = ref(false)
const pwdForm = reactive({ account: '', new_password: '' })
function openReset(row: any) {
Object.assign(pwdForm, { account: row.account, new_password: '' })
pwdOpen.value = true
}
async function submitReset() {
if (!pwdForm.new_password || pwdForm.new_password.length < 8) {
return ElMessage.warning('新密码至少 8 位')
}
await resetAccountPwd({ account: pwdForm.account, new_password: pwdForm.new_password })
ElMessage.success('密码已重置')
pwdOpen.value = false
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除账号「${row.account}」?`, '删除确认', { type: 'warning' })
await deleteAccount(row.account)
ElMessage.success('已删除')
load()
}
onMounted(load)
</script>
<template>
<div class="p-5 space-y-4">
<ArtPageHeader title="账号管理" description="统一账号维护、管理员标识与授权概览">
<template #actions>
<el-button type="primary" @click="openCreate"><ArtSvgIcon icon="ri:add-line" class="mr-1" />新建账号</el-button>
</template>
</ArtPageHeader>
<el-card shadow="never" class="rounded-xl">
<el-form inline @submit.prevent="search">
<el-form-item label="关键字">
<el-input v-model="query.q" placeholder="账号 / 昵称 / 部门" clearable style="width: 240px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
<el-button @click="Object.assign(query, { q: '' }); search()">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card shadow="never" class="rounded-xl">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column prop="account" label="账号" min-width="120" />
<el-table-column prop="nickname" label="昵称" min-width="120" />
<el-table-column prop="dept" label="部门" width="120" />
<el-table-column label="管理员" width="90">
<template #default="{ row }">
<el-tag v-if="row.is_admin" size="small" type="primary">管理员</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="90">
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'danger'" size="small">
{{ row.status === 1 ? '启用' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="插件授权" width="110">
<template #default="{ row }">
<el-tag v-if="row.plugins?.length" size="small" type="info">{{ row.plugins.length }} 个</el-tag>
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="170" />
<el-table-column label="操作" width="220" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="warning" @click="openReset(row)">重置密码</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<el-pagination
v-model:current-page="query.page"
v-model:page-size="query.page_size"
:total="total"
layout="total, prev, pager, next"
@current-change="load"
/>
</div>
</el-card>
<!-- 新建/编辑弹窗 -->
<el-dialog v-model="dialogOpen" :title="isEdit ? '编辑账号' : '新建账号'" width="480px">
<el-form label-width="90px">
<el-form-item label="账号" required>
<el-input v-model="form.account" :disabled="isEdit" placeholder="账户编号(工号等)" />
</el-form-item>
<el-form-item v-if="!isEdit" label="初始密码" required>
<el-input v-model="form.password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="form.nickname" />
</el-form-item>
<el-form-item label="部门">
<el-input v-model="form.dept" />
</el-form-item>
<el-form-item label="管理员">
<el-switch v-model="form.is_admin" />
</el-form-item>
<el-form-item v-if="isEdit" label="状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="停用" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogOpen = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
</template>
</el-dialog>
<!-- 重置密码弹窗 -->
<el-dialog v-model="pwdOpen" title="重置密码" width="420px">
<el-form label-width="90px">
<el-form-item label="账号">{{ pwdForm.account }}</el-form-item>
<el-form-item label="新密码" required>
<el-input v-model="pwdForm.new_password" type="password" show-password placeholder="至少 8 位" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="pwdOpen = false">取消</el-button>
<el-button type="primary" @click="submitReset">重置</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -13,9 +13,12 @@ const today = ref(0)
const query = reactive({ page: 1, page_size: 20, action: '', q: '' })
const actionOptions = ['account-create', 'account-update', 'account-reset-pwd', 'account-delete',
'grant', 'revoke-grant', 'grant-platform', 'revoke-platform', 'plugin-publish', 'plugin-delete',
'plugin-patch', 'shell-release', 'file-source-upsert', 'file-source-patch', 'file-source-delete',
'creds-seed', 'notify-create', 'notify-toggle', 'notify-delete', 'download-ticket']
'grant', 'revoke-grant', 'grant-platform', 'revoke-platform', 'grant-batch', 'grant-revoke-batch',
'plugin-publish', 'plugin-delete', 'plugin-patch', 'shell-release', 'file-source-upsert',
'file-source-patch', 'file-source-delete', 'creds-seed', 'notify-create', 'notify-toggle',
'notify-delete', 'download-ticket', 'sys-user-add', 'sys-user-edit', 'sys-user-del',
'sys-role-add', 'sys-role-edit', 'sys-role-del', 'sys-menu-add', 'sys-menu-edit', 'sys-menu-del',
'sys-dept-add', 'sys-dept-edit', 'sys-dept-del']
async function load() {
loading.value = true
@@ -1,62 +0,0 @@
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="relative flex-1">
<AuthTopBar />
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('forgetPassword.title') }}</h3>
<p class="sub-title">{{ $t('forgetPassword.subTitle') }}</p>
<div class="mt-5">
<span class="input-label" v-if="showInputLabel">账号</span>
<ElInput
class="custom-height"
:placeholder="$t('forgetPassword.placeholder')"
v-model.trim="username"
/>
</div>
<div style="margin-top: 15px">
<ElButton
class="w-full custom-height"
type="primary"
@click="register"
:loading="loading"
v-ripple
>
{{ $t('forgetPassword.submitBtnText') }}
</ElButton>
</div>
<div style="margin-top: 15px">
<ElButton class="w-full custom-height" plain @click="toLogin">
{{ $t('forgetPassword.backBtnText') }}
</ElButton>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
defineOptions({ name: 'ForgetPassword' })
const router = useRouter()
const showInputLabel = ref(false)
const username = ref('')
const loading = ref(false)
const register = async () => {}
const toLogin = () => {
router.push({ name: 'Login' })
}
</script>
<style scoped>
@import '../login/style.css';
</style>
@@ -1,120 +1,126 @@
<!-- 登录页面(37du 重构版:统一账户 + 密码 → cool-admin /api/admin/auth) -->
<!-- 登录页(37du:极光背景 + 玻璃拟态卡片;统一账户 + 密码 → /api/admin/auth) -->
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="login-page">
<AuthTopBar />
<div class="relative flex-1">
<AuthTopBar />
<!-- 极光光斑 -->
<div class="blob blob-1"></div>
<div class="blob blob-2"></div>
<div class="blob blob-3"></div>
<!-- 点阵纹理 -->
<div class="grid-overlay"></div>
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('login.title') }}</h3>
<p class="sub-title">{{ $t('login.subTitle') }}</p>
<ElForm
ref="formRef"
:model="formData"
:rules="rules"
:key="formKey"
@keyup.enter="handleSubmit"
style="margin-top: 25px"
>
<ElFormItem prop="account">
<ElInput
class="custom-height"
:placeholder="'工号 / 账号'"
v-model.trim="formData.account"
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="custom-height"
:placeholder="$t('login.placeholder.password')"
v-model.trim="formData.password"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<!-- 左上角品牌 -->
<div class="corner-brand">
<ArtLogo size="30" />
<span>37du 控制台</span>
</div>
<!-- 拖拽验证 -->
<div class="relative pb-5 mt-6">
<div
class="relative z-[2] overflow-hidden select-none rounded-lg border border-transparent tad-300"
:class="{ '!border-[#FF4E4F]': !isPassing && isClickPass }"
>
<ArtDragVerify
ref="dragVerify"
v-model:value="isPassing"
:text="$t('login.sliderText')"
textColor="var(--art-gray-700)"
:successText="$t('login.sliderSuccessText')"
progressBarBg="var(--main-color)"
:background="isDark ? '#26272F' : '#F1F1F4'"
handlerBg="var(--default-box-color)"
/>
</div>
<p
class="absolute top-0 z-[1] px-px mt-2 text-xs text-[#f56c6c] tad-300"
:class="{ 'translate-y-10': !isPassing && isClickPass }"
>
{{ $t('login.placeholder.slider') }}
</p>
</div>
<div style="margin-top: 30px">
<ElButton
class="w-full custom-height"
type="primary"
@click="handleSubmit"
:loading="loading"
v-ripple
>
{{ $t('login.btnText') }}
</ElButton>
</div>
</ElForm>
<!-- 玻璃卡片 -->
<div class="login-card">
<div class="card-head">
<div class="brand-mark">
<ArtLogo size="46" />
</div>
<h2 class="title">{{ greeting }}</h2>
<p class="sub-title">登录 37du 控制台,继续管理插件与执行机</p>
</div>
<ElForm
ref="formRef"
:model="formData"
:rules="rules"
@keyup.enter="handleSubmit"
class="login-form"
>
<ElFormItem prop="account">
<ElInput
class="glass-input"
:prefix-icon="User"
placeholder="账户"
v-model.trim="formData.account"
clearable
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="glass-input"
:prefix-icon="Lock"
placeholder="密码"
v-model.trim="formData.password"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<div class="form-opts">
<el-checkbox v-model="rememberAccount">记住账户</el-checkbox>
</div>
<ElButton
class="login-btn"
type="primary"
@click="handleSubmit"
:loading="loading"
v-ripple
>
<span v-if="!loading">登录控制台</span>
</ElButton>
</ElForm>
<div class="feature-row">
<div class="feature"><ArtSvgIcon icon="ri:box-3-line" /><span>插件分发</span></div>
<div class="feature"><ArtSvgIcon icon="ri:key-2-line" /><span>账号授权</span></div>
<div class="feature"><ArtSvgIcon icon="ri:line-chart-line" /><span>运行监控</span></div>
</div>
</div>
<div class="page-footer">
<ArtSvgIcon icon="ri:shield-keyhole-line" />
37du 自动化平台 · 内部系统 · 请妥善保管账户信息
</div>
</div>
</template>
<script setup lang="ts">
import { User, Lock } from '@element-plus/icons-vue'
import { useUserStore } from '@/store/modules/user'
import { useI18n } from 'vue-i18n'
import { HttpError } from '@/utils/http/error'
import { fetchLogin, fetchGetUserInfo, fetchUserMenus } from '@/api/auth'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { useSettingStore } from '@/store/modules/setting'
import AuthTopBar from '@/components/core/views/login/AuthTopBar.vue'
defineOptions({ name: 'Login' })
const settingStore = useSettingStore()
const { isDark } = storeToRefs(settingStore)
const { t, locale } = useI18n()
const formKey = ref(0)
const REMEMBER_KEY = '37du-login-account'
watch(locale, () => {
formKey.value++
})
const dragVerify = ref()
const userStore = useUserStore()
const router = useRouter()
const route = useRoute()
const isPassing = ref(false)
const isClickPass = ref(false)
const formRef = ref<FormInstance>()
// 按时段问候
const greeting = computed(() => {
const h = new Date().getHours()
if (h >= 5 && h < 9) return '早上好'
if (h >= 9 && h < 12) return '上午好'
if (h >= 12 && h < 14) return '中午好'
if (h >= 14 && h < 18) return '下午好'
return '晚上好'
})
const formData = reactive({
account: '',
account: localStorage.getItem(REMEMBER_KEY) || '',
password: ''
})
const rules = computed<FormRules>(() => ({
account: [{ required: true, message: '请输入工号/账号', trigger: 'blur' }],
password: [{ required: true, message: t('login.placeholder.password'), trigger: 'blur' }]
}))
const rememberAccount = ref(!!formData.account)
const rules: FormRules = {
account: [{ required: true, message: '请输入账户', trigger: 'blur' }],
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
}
const loading = ref(false)
@@ -124,10 +130,6 @@
try {
const valid = await formRef.value.validate()
if (!valid) return
if (!isPassing.value) {
isClickPass.value = true
return
}
loading.value = true
const login = await fetchLogin({ account: formData.account, password: formData.password })
@@ -146,15 +148,25 @@
console.error('[Login] fetch me/menus failed:', e)
}
// 初始密码强制改密提示
// 记住账户
try {
if (rememberAccount.value) localStorage.setItem(REMEMBER_KEY, formData.account)
else localStorage.removeItem(REMEMBER_KEY)
} catch (e) {
/* ignore */
}
// 初始密码强制改密:直接引导到个人中心改密页
if (login.must_change_pwd) {
ElMessage.warning('首次登录请尽快修改初始密码')
ElMessage.warning('当前为初始密码,请先修改密码后再使用')
router.push('/system/user-center')
return
}
const redirect = route.query.redirect as string
router.push(redirect || '/')
} catch (error) {
// 展示具体错误(如"账号或密码错误"),而非笼统提示
// 展示具体错误(如"账户或密码错误"),而非笼统提示
if (error instanceof HttpError) {
ElMessage.error(error.message)
} else {
@@ -163,21 +175,10 @@
}
} finally {
loading.value = false
resetDragVerify()
}
}
const resetDragVerify = () => {
dragVerify.value?.reset()
}
</script>
<style scoped>
@import './style.css';
</style>
<style lang="scss" scoped>
:deep(.el-input__wrapper) {
height: 40px !important;
}
</style>
@@ -1,38 +1,366 @@
@reference '@styles/core/tailwind.css';
/* 授权页右侧区域 */
.auth-right-wrap {
@apply absolute inset-0 w-[440px] h-[650px] py-[5px] m-auto overflow-hidden
max-sm:px-7 max-sm:w-full
animate-[slideInRight_0.6s_cubic-bezier(0.25,0.46,0.45,0.94)_forwards]
max-md:animate-none;
.form {
@apply h-full py-[40px];
}
.title {
@apply text-g-900 text-4xl font-semibold max-md:text-3xl max-sm:pt-10;
}
.sub-title {
@apply mt-[10px] text-g-600 text-sm;
}
.custom-height {
@apply !h-[40px];
}
}
/* 滑入动画 */
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(30px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
/* ============================================================
登录页:极光动态背景 + 点阵纹理 + 玻璃拟态卡片 + 微交互
适配明暗主题与主题色切换(全部走 CSS 变量)
============================================================ */
.login-page {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100vh;
overflow: hidden;
background: var(--main-bg, #f5f7fb);
}
/* ---------- 极光光斑(大范围模糊,缓慢漂浮) ---------- */
.blob {
position: absolute;
border-radius: 50%;
filter: blur(90px);
opacity: 0.55;
pointer-events: none;
will-change: transform;
}
.blob-1 {
top: -180px;
left: -120px;
width: 560px;
height: 560px;
background: radial-gradient(circle at 35% 35%,
color-mix(in srgb, var(--el-color-primary) 55%, transparent), transparent 70%);
animation: drift-a 16s ease-in-out infinite alternate;
}
.blob-2 {
right: -160px;
bottom: -200px;
width: 620px;
height: 620px;
background: radial-gradient(circle at 60% 60%,
rgba(124, 92, 255, 0.5), transparent 70%);
animation: drift-b 20s ease-in-out infinite alternate;
}
.blob-3 {
top: 40%;
left: 58%;
width: 380px;
height: 380px;
background: radial-gradient(circle at 50% 50%,
rgba(0, 200, 255, 0.38), transparent 70%);
animation: drift-c 18s ease-in-out infinite alternate;
}
@keyframes drift-a {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(90px, 60px) scale(1.12); }
}
@keyframes drift-b {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-80px, -70px) scale(1.08); }
}
@keyframes drift-c {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(-60px, 50px) scale(1.15); }
}
/* ---------- 点阵纹理(径向渐隐) ---------- */
.grid-overlay {
position: absolute;
inset: 0;
pointer-events: none;
background-image: radial-gradient(
circle,
color-mix(in srgb, var(--art-gray-400, #9ca3af) 55%, transparent) 1px,
transparent 1px
);
background-size: 26px 26px;
-webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 30%, transparent 75%);
mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 30%, transparent 75%);
opacity: 0.4;
}
/* ---------- 左上角品牌 ---------- */
.corner-brand {
position: absolute;
top: 22px;
left: 26px;
z-index: 20;
display: flex;
align-items: center;
gap: 9px;
font-size: 14px;
font-weight: 500;
color: var(--art-gray-700);
}
/* ---------- 玻璃拟态卡片 ---------- */
.login-card {
position: relative;
z-index: 10;
box-sizing: border-box;
width: 430px;
max-width: calc(100vw - 32px);
padding: 38px 38px 26px;
overflow: hidden;
background: rgba(255, 255, 255, 0.62);
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 24px;
box-shadow:
0 30px 80px rgba(31, 38, 88, 0.16),
inset 0 1px 0 rgba(255, 255, 255, 0.7);
backdrop-filter: blur(22px) saturate(160%);
-webkit-backdrop-filter: blur(22px) saturate(160%);
animation: cardIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes cardIn {
from {
opacity: 0;
transform: translateY(26px) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
/* 顶部主题色流光条 */
.login-card::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 3px;
content: '';
background: linear-gradient(90deg,
var(--el-color-primary),
rgba(124, 92, 255, 0.9),
rgba(0, 200, 255, 0.9),
var(--el-color-primary));
background-size: 300% 100%;
animation: sheen 6s linear infinite;
}
@keyframes sheen {
0% { background-position: 0% 0; }
100% { background-position: 300% 0; }
}
.card-head {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.brand-mark {
display: flex;
align-items: center;
justify-content: center;
width: 68px;
height: 68px;
margin-bottom: 16px;
background: var(--default-box-color);
border: 1px solid var(--art-border-color, rgba(0, 0, 0, 0.06));
border-radius: 20px;
box-shadow: 0 10px 26px rgba(31, 38, 88, 0.12);
}
.title {
margin: 0;
font-size: 26px;
font-weight: 700;
letter-spacing: 1px;
color: var(--art-gray-900);
}
.sub-title {
margin: 8px 0 0;
font-size: 13px;
color: var(--art-gray-500);
}
/* ---------- 表单 ---------- */
.login-form {
margin-top: 26px;
}
.login-form :deep(.el-form-item) {
margin-bottom: 18px;
}
/* 玻璃质感输入框 */
.login-form :deep(.el-input__wrapper) {
height: 44px;
padding: 0 14px;
background: rgba(255, 255, 255, 0.55);
border-radius: 12px;
box-shadow: 0 0 0 1px var(--art-border-color, rgba(0, 0, 0, 0.08)) inset;
transition: box-shadow 0.25s, background 0.25s;
}
.login-form :deep(.el-input__wrapper:hover) {
box-shadow: 0 0 0 1px color-mix(in srgb, var(--el-color-primary) 45%, transparent) inset;
}
.login-form :deep(.el-input__wrapper.is-focus) {
background: rgba(255, 255, 255, 0.85);
box-shadow:
0 0 0 1px var(--el-color-primary) inset,
0 0 0 4px color-mix(in srgb, var(--el-color-primary) 14%, transparent);
}
.form-opts {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: -6px;
}
/* 渐变主按钮 */
.login-btn {
width: 100%;
height: 44px;
margin-top: 8px;
font-size: 15px;
font-weight: 600;
letter-spacing: 4px;
border: none;
background: linear-gradient(135deg,
var(--el-color-primary) 0%,
color-mix(in srgb, var(--el-color-primary) 72%, #7c5cff) 100%);
box-shadow: 0 10px 24px color-mix(in srgb, var(--el-color-primary) 35%, transparent);
transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.login-btn:hover {
transform: translateY(-1px);
filter: brightness(1.06);
box-shadow: 0 14px 30px color-mix(in srgb, var(--el-color-primary) 45%, transparent);
}
.login-btn:active {
transform: translateY(0) scale(0.99);
}
/* ---------- 特性胶囊 ---------- */
.feature-row {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 22px;
}
.feature {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 14px;
font-size: 12px;
color: var(--art-gray-600);
cursor: default;
background: color-mix(in srgb, var(--el-color-primary) 7%, transparent);
border-radius: 999px;
transition: all 0.2s;
}
.feature svg {
color: var(--el-color-primary);
font-size: 14px;
}
.feature:hover {
color: var(--el-color-primary);
background: color-mix(in srgb, var(--el-color-primary) 14%, transparent);
transform: translateY(-1px);
}
/* ---------- 页脚 ---------- */
.page-footer {
position: absolute;
bottom: 20px;
left: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
width: 100%;
font-size: 12px;
color: var(--art-gray-500);
}
/* ---------- 暗色主题 ---------- */
.dark .login-page {
background: #101116;
}
.dark .blob {
opacity: 0.42;
}
.dark .grid-overlay {
background-image: radial-gradient(
circle,
rgba(255, 255, 255, 0.16) 1px,
transparent 1px
);
opacity: 0.3;
}
.dark .corner-brand {
color: var(--art-gray-300);
}
.dark .login-card {
background: rgba(24, 25, 31, 0.62);
border: 1px solid rgba(255, 255, 255, 0.09);
box-shadow:
0 30px 80px rgba(0, 0, 0, 0.5),
inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.dark .login-form :deep(.el-input__wrapper) {
background: rgba(255, 255, 255, 0.05);
}
.dark .login-form :deep(.el-input__wrapper.is-focus) {
background: rgba(255, 255, 255, 0.09);
}
.dark .brand-mark {
background: rgba(255, 255, 255, 0.04);
border-color: rgba(255, 255, 255, 0.08);
}
.dark .title {
color: var(--art-gray-100);
}
.dark .feature {
background: rgba(255, 255, 255, 0.05);
color: var(--art-gray-300);
}
.dark .page-footer {
color: var(--art-gray-500);
}
/* ---------- 小屏适配 ---------- */
@media (width <= 640px) {
.login-card {
padding: 30px 22px 20px;
border-radius: 18px;
}
.corner-brand {
display: none;
}
}
@@ -1,240 +0,0 @@
<!-- 注册页面 -->
<template>
<div class="flex w-full h-screen">
<LoginLeftView />
<div class="relative flex-1">
<AuthTopBar />
<div class="auth-right-wrap">
<div class="form">
<h3 class="title">{{ $t('register.title') }}</h3>
<p class="sub-title">{{ $t('register.subTitle') }}</p>
<ElForm
class="mt-7.5"
ref="formRef"
:model="formData"
:rules="rules"
label-position="top"
:key="formKey"
>
<ElFormItem prop="username">
<ElInput
class="custom-height"
v-model.trim="formData.username"
:placeholder="$t('register.placeholder.username')"
/>
</ElFormItem>
<ElFormItem prop="password">
<ElInput
class="custom-height"
v-model.trim="formData.password"
:placeholder="$t('register.placeholder.password')"
type="password"
autocomplete="off"
show-password
/>
</ElFormItem>
<ElFormItem prop="confirmPassword">
<ElInput
class="custom-height"
v-model.trim="formData.confirmPassword"
:placeholder="$t('register.placeholder.confirmPassword')"
type="password"
autocomplete="off"
@keyup.enter="register"
show-password
/>
</ElFormItem>
<ElFormItem prop="agreement">
<ElCheckbox v-model="formData.agreement">
{{ $t('register.agreeText') }}
<RouterLink
style="color: var(--theme-color); text-decoration: none"
to="/privacy-policy"
>{{ $t('register.privacyPolicy') }}</RouterLink
>
</ElCheckbox>
</ElFormItem>
<div style="margin-top: 15px">
<ElButton
class="w-full custom-height"
type="primary"
@click="register"
:loading="loading"
v-ripple
>
{{ $t('register.submitBtnText') }}
</ElButton>
</div>
<div class="mt-5 text-sm text-g-600">
<span>{{ $t('register.hasAccount') }}</span>
<RouterLink class="text-theme" :to="{ name: 'Login' }">{{
$t('register.toLogin')
}}</RouterLink>
</div>
</ElForm>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import type { FormInstance, FormRules } from 'element-plus'
defineOptions({ name: 'Register' })
interface RegisterForm {
username: string
password: string
confirmPassword: string
agreement: boolean
}
const USERNAME_MIN_LENGTH = 3
const USERNAME_MAX_LENGTH = 20
const PASSWORD_MIN_LENGTH = 6
const REDIRECT_DELAY = 1000
const { t, locale } = useI18n()
const router = useRouter()
const formRef = ref<FormInstance>()
const loading = ref(false)
const formKey = ref(0)
// 监听语言切换,重置表单
watch(locale, () => {
formKey.value++
})
const formData = reactive<RegisterForm>({
username: '',
password: '',
confirmPassword: '',
agreement: false
})
/**
* 验证密码
* 当密码输入后,如果确认密码已填写,则触发确认密码的验证
*/
const validatePassword = (_rule: any, value: string, callback: (error?: Error) => void) => {
if (!value) {
callback(new Error(t('register.placeholder.password')))
return
}
if (formData.confirmPassword) {
formRef.value?.validateField('confirmPassword')
}
callback()
}
/**
* 验证确认密码
* 检查确认密码是否与密码一致
*/
const validateConfirmPassword = (
_rule: any,
value: string,
callback: (error?: Error) => void
) => {
if (!value) {
callback(new Error(t('register.rule.confirmPasswordRequired')))
return
}
if (value !== formData.password) {
callback(new Error(t('register.rule.passwordMismatch')))
return
}
callback()
}
/**
* 验证用户协议
* 确保用户已勾选同意协议
*/
const validateAgreement = (_rule: any, value: boolean, callback: (error?: Error) => void) => {
if (!value) {
callback(new Error(t('register.rule.agreementRequired')))
return
}
callback()
}
const rules = computed<FormRules<RegisterForm>>(() => ({
username: [
{ required: true, message: t('register.placeholder.username'), trigger: 'blur' },
{
min: USERNAME_MIN_LENGTH,
max: USERNAME_MAX_LENGTH,
message: t('register.rule.usernameLength'),
trigger: 'blur'
}
],
password: [
{ required: true, validator: validatePassword, trigger: 'blur' },
{ min: PASSWORD_MIN_LENGTH, message: t('register.rule.passwordLength'), trigger: 'blur' }
],
confirmPassword: [{ required: true, validator: validateConfirmPassword, trigger: 'blur' }],
agreement: [{ validator: validateAgreement, trigger: 'change' }]
}))
/**
* 注册用户
* 验证表单后提交注册请求
*/
const register = async () => {
if (!formRef.value) return
try {
await formRef.value.validate()
loading.value = true
// TODO: 替换为真实 API 调用
// const params = {
// username: formData.username,
// password: formData.password
// }
// const res = await AuthService.register(params)
// if (res.code === ApiStatus.success) {
// ElMessage.success('注册成功')
// toLogin()
// }
// 模拟注册请求
setTimeout(() => {
loading.value = false
ElMessage.success('注册成功')
toLogin()
}, REDIRECT_DELAY)
} catch (error) {
console.error('表单验证失败:', error)
loading.value = false
}
}
/**
* 跳转到登录页面
*/
const toLogin = () => {
setTimeout(() => {
router.push({ name: 'Login' })
}, REDIRECT_DELAY)
}
</script>
<style scoped>
@import '../login/style.css';
</style>
@@ -25,7 +25,7 @@ async function loadAccounts() {
accounts.value = d.accounts || []
accountsLoaded.value = true
} catch (e) {
/* 拉取失败不阻断,仍可手输工号 */
/* 拉取失败不阻断,仍可手动输入账号 */
}
}
@@ -158,7 +158,7 @@ onMounted(load)
<el-select
v-model="form.account"
filterable
placeholder="搜索昵称 / 工号选择账号"
placeholder="搜索昵称 / 账号选择"
style="width: 100%"
>
<el-option
@@ -71,6 +71,50 @@ async function setStatus(row: any, status: string) {
load()
}
// ---- 强制更新 ----
const forceOpen = ref(false)
const forceSaving = ref(false)
const forceForm = reactive({ plugin_id: '', force_min_version: '', force_deadline: '' })
function openForce(row: any) {
Object.assign(forceForm, {
plugin_id: row.id,
force_min_version: row.force_min_version || '',
force_deadline: row.force_deadline || ''
})
forceOpen.value = true
}
async function submitForce() {
if (!forceForm.force_min_version || !forceForm.force_deadline) {
ElMessage.warning('最低版本与截止时间必须同时填写')
return
}
forceSaving.value = true
try {
await patchPlugin(forceForm.plugin_id, {
force_min_version: forceForm.force_min_version,
force_deadline: forceForm.force_deadline
})
ElMessage.success(`已设置强制更新:低于 v${forceForm.force_min_version} 的执行机将在截止时间前强制升级`)
forceOpen.value = false
load()
} finally {
forceSaving.value = false
}
}
async function clearForce(row: any) {
await ElMessageBox.confirm(`清除插件「${row.id}」的强制更新设置?`, '确认', { type: 'warning' })
await patchPlugin(row.id, { clear_force: true })
ElMessage.success('已清除强制更新')
load()
}
function fmtDeadline(s: string): string {
return String(s || '').replace('T', ' ').slice(0, 16)
}
// ---- 删除 ----
async function remove(row: any) {
await ElMessageBox.confirm(`确认删除插件「${row.id}」?将连带删除版本与授权。`, '删除确认', {
@@ -119,7 +163,7 @@ onMounted(load)
</el-tag>
</template>
</el-table-column>
<el-table-column label="版本历史" width="220">
<el-table-column label="版本历史" width="100">
<template #default="{ row }">
<el-tooltip v-if="row.versions?.length" :content="row.versions.map((v: any) => v.version).join(', ')">
<el-tag size="small" type="info">{{ row.versions.length }} 个版本</el-tag>
@@ -127,7 +171,20 @@ onMounted(load)
<span v-else class="text-gray-400">-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="220" fixed="right">
<el-table-column label="强制更新" min-width="170">
<template #default="{ row }">
<el-tooltip
v-if="row.force_min_version"
:content="`低于 v${row.force_min_version} 的执行机须在 ${fmtDeadline(row.force_deadline)} 前完成升级`"
>
<el-tag size="small" type="danger" effect="light">
≥v{{ row.force_min_version }} · 至 {{ fmtDeadline(row.force_deadline) }}
</el-tag>
</el-tooltip>
<span v-else class="text-gray-300 text-xs">未设置</span>
</template>
</el-table-column>
<el-table-column label="操作" width="250" fixed="right">
<template #default="{ row }">
<el-button
v-if="row.status === 'disabled'"
@@ -144,6 +201,8 @@ onMounted(load)
link type="danger"
@click="setStatus(row, 'revoked')"
>下架</el-button>
<el-button link type="warning" @click="openForce(row)">强制更新</el-button>
<el-button v-if="row.force_min_version" link type="info" @click="clearForce(row)">清除</el-button>
<el-button link type="danger" @click="remove(row)">删除</el-button>
</template>
</el-table-column>
@@ -180,5 +239,31 @@ onMounted(load)
<el-button type="primary" :loading="uploading" @click="submitUpload">发布</el-button>
</template>
</el-dialog>
<!-- 强制更新弹窗 -->
<el-dialog v-model="forceOpen" :title="`强制更新 — ${forceForm.plugin_id}`" width="480px">
<el-form label-width="100px">
<el-form-item label="最低版本" required>
<el-input v-model="forceForm.force_min_version" placeholder="如 1.3.0(低于该版本将强制升级)" />
</el-form-item>
<el-form-item label="截止时间" required>
<el-date-picker
v-model="forceForm.force_deadline"
type="datetime"
placeholder="选择强制升级截止时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</el-form-item>
<div class="px-1 text-xs text-gray-400 leading-5">
设置后:客户端 /api/plugins 将下发 force_min_version 与 force_deadline,
执行机壳子对低于最低版本的插件在截止时间前强制升级(旧版本不可继续运行)。
</div>
</el-form>
<template #footer>
<el-button @click="forceOpen = false">取消</el-button>
<el-button type="primary" :loading="forceSaving" @click="submitForce">设置</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -2,7 +2,7 @@ import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'url'
import vueDevTools from 'vite-plugin-vue-devtools'
// import vueDevTools from 'vite-plugin-vue-devtools' // Vue DevTools 悬浮调试入口已移除(内部系统不需要;生产构建本就不含)
import viteCompression from 'vite-plugin-compression'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
@@ -106,7 +106,7 @@ export default ({ mode }: { mode: string }) => {
threshold: 10240, // 只有大小大于该值的资源会被处理 10240B = 10KB
deleteOriginFile: false // 压缩后是否删除原文件
}),
vueDevTools()
// Vue DevTools 悬浮调试入口已移除(内部系统不需要;生产构建本就不含)
// 打包分析
// visualizer({
// open: true,