<template> <div class="login-container"> <div class="login-form"> <h2>用户登录</h2> <input v-model="username" placeholder="用户名"> <input v-model="password" type="password" placeholder="密码"> <button @click="handleLogin">登录</button> <!-- <router-link to="/register">注册账号</router-link> --> </div> </div> </template> <script setup> import { ref } from 'vue' import { useRouter } from 'vue-router' import axios from 'axios' import { ElMessage } from 'element-plus' const router = useRouter() const username = ref('') const password = ref('') const handleLogin = async () => { try { // 发送POST请求到登录接口 const response = await axios.post('http://172.26.26.43/dev-api/login', { username: username.value, password: password.value }) const { code, message, token } = response.data // 根据状态码判断登录是否成功 if (code === 200) { // 存储token到localStorage localStorage.setItem('token', token) ElMessage.success({ message:'登录成功!', customClass:'mobile-message', duration: 1000 }) setTimeout(() => { // 登录成功后跳转到详情页 router.push({ name: 'Detail' , params: { id: 123 } }) }, 1000) } else { alert(`登录失败: ${message}`) } } catch (error) { // 处理请求错误 console.error('登录请求出错:', error) alert('登录请求失败,请检查网络或联系管理员') } } </script> <style scoped> /* 添加移动端适配的样式 */ .login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; /* 使容器至少和视口一样高 */ background-color: #f5f5f5; /* 背景色 */ padding: 16px; /* 内边距 */ } .login-form { width: 100%; max-width: 400px; /* 最大宽度,避免在大屏幕上过宽 */ padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } .login-form h2 { text-align: center; margin-bottom: 20px; color: #333; } .login-form input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; box-sizing: border-box; /* 确保宽度包含内边距和边框 */ } .login-form button { width: 100%; padding: 12px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; } /* 按钮的点击区域已经足够大(高度44px左右) */ .login-form button:active { background-color: #0056b3; } .login-form a { display: block; text-align: center; margin-top: 12px; color: #007bff; text-decoration: none; } </style> 这个是我的登录界面,我在登录成功后获取到接口返回的token,在详情页面会用到这个token,详情界面代码:<template> <div class="detail-container"> <!-- 索引板块卡片 --> <el-card class="index-card"> <!-- 表单区域 --> <el-form :model="formData" label-position="top" ref="indexForm" class="mobile-form" > <!-- 问卷标题 --> <el-form-item label="问卷标题:" prop="dcWjTitle"> <el-input v-model="formData.dcWjTitle" placeholder="请输入问卷标题" clearable :prefix-icon="Document" /> </el-form-item> <!-- 被测评人 --> <el-form-item label="被测评人:" prop="dcId"> <el-input v-model="formData.dcId" placeholder="请输入被测评人ID" clearable :prefix-icon="User" /> </el-form-item> <!-- 人员部门 --> <el-form-item label="人员部门:" prop="dcDept"> <el-input v-model="formData.dcDept" placeholder="请输入人员部门" clearable :prefix-icon="OfficeBuilding" /> </el-form-item> <!-- 提交状态 --> <el-form-item label="提交状态:" prop="state"> <el-select v-model="formData.state" placeholder="请选择提交状态" clearable class="mobile-select" > <el-option label="已提交" :value="1" /> <el-option label="未提交" :value="0" /> </el-select> </el-form-item> <!-- 新增:按钮区域 --> <el-form-item class="button-group"> <el-button type="primary" @click="handleSearch" class="action-button" :icon="Search" > 搜索 </el-button> <el-button @click="handleReset" class="action-button" :icon="Refresh" > 重置 </el-button> </el-form-item> </el-form> </el-card> <!-- 数据显示板块 --> <el-card class="data-card"> <template #header> <div class="card-header"> <span>测评数据列表</span> <el-button type="primary" size="small" :icon="Refresh" @click="fetchData" > 刷新数据 </el-button> </div> </template> <!-- 数据表格 --> <el-table :data="tableData" v-loading="loading" element-loading-text="数据加载中..." stripe style="width: 100%" class="mobile-table" > <el-table-column prop="id" label="ID" width="80" /> <el-table-column prop="dcWjTitle" label="问卷标题" min-width="150" /> <el-table-column prop="dcId" label="被测评人ID" width="120" /> <el-table-column prop="dcDept" label="部门" width="120" /> <el-table-column prop="state" label="提交状态" width="100"> <template #default="scope"> <el-tag :type="scope.row.state === 1 ? 'success' : 'info'"> {{ scope.row.state === 1 ? '已提交' : '未提交' }} </el-tag> </template> </el-table-column> <el-table-column prop="createTime" label="创建时间" width="180" /> <el-table-column label="操作" width="120" fixed="right"> <template #default="scope"> <el-button size="small" type="primary" @click="handleView(scope.row)" > 查看 </el-button> </template> </el-table-column> </el-table> <!-- 分页控件 --> <div class="pagination-container"> <el-pagination v-model:current-page="pagination.current" v-model:page-size="pagination.size" :page-sizes="[5, 10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" @size-change="handleSizeChange" @current-change="handlePageChange" /> </div> </el-card> </div> </template> <script setup> // 确保正确导入所有 Vue 函数 import { ref, reactive, onMounted, onUnmounted } from 'vue'; import axios from 'axios'; import { Document, User, OfficeBuilding, Search, Refresh } from '@element-plus/icons-vue'; import { ElMessage } from 'element-plus'; // 环境变量管理API地址 const API_BASE = import.meta.env.VITE_API_BASE || 'http://172.26.26.43/dev-api'; const API_URL = `${API_BASE}/wjdc/wj/listTx`; // 表单数据 const formData = reactive({ dcWjTitle: '', dcId: '', dcDept: '', state: null }); // 表格数据 const tableData = ref([]); const loading = ref(false); // 分页配置 const pagination = reactive({ current: 1, size: 10, total: 0 }); // 表单引用 const indexForm = ref(null); // 请求取消令牌 let cancelTokenSource = axios.CancelToken.source(); // 搜索按钮处理函数 - 添加防抖 let searchTimer = null; const handleSearch = () => { if (searchTimer) clearTimeout(searchTimer); searchTimer = setTimeout(() => { pagination.current = 1; fetchData(); }, 300); }; // 重置按钮处理函数 const handleReset = () => { if (indexForm.value) { indexForm.value.resetFields(); } handleSearch(); }; // 查看详情 const handleView = (row) => { console.log('查看详情:', row); // 这里可以实现查看详情的逻辑 }; // 分页大小改变 const handleSizeChange = (size) => { pagination.size = size; fetchData(); }; // 页码改变 const handlePageChange = (page) => { pagination.current = page; fetchData(); }; // 获取数据 const fetchData = async () => { // 取消之前的请求 if (cancelTokenSource) { cancelTokenSource.cancel('请求被取消'); } cancelTokenSource = axios.CancelToken.source(); loading.value = true; try { // 构造请求参数 const params = { pageNum: pagination.current, pageSize: pagination.size, ...formData }; // 调用API const response = await axios.get(API_URL, { params, cancelToken: cancelTokenSource.token, headers: { 'Content-Type': 'application/json' } }); // 处理响应数据 const { data } = response; if (data && data.code === 200) { tableData.value = data.data.rows || []; pagination.total = data.data.total || 0; // 空数据提示 if (tableData.value.length === 0) { ElMessage.info('没有找到匹配的数据'); } } else { const errorMsg = data?.msg || '未知错误'; console.error('API返回错误:', errorMsg); ElMessage.error(`请求失败: ${errorMsg}`); tableData.value = []; pagination.total = 0; } } catch (error) { // 忽略取消请求的错误 if (!axios.isCancel(error)) { console.error('获取数据失败:', error); ElMessage.error('网络请求失败,请稍后重试'); tableData.value = []; pagination.total = 0; } } finally { loading.value = false; } }; // 页面加载时获取初始数据 onMounted(() => { fetchData(); }); // 组件卸载时取消所有请求 onUnmounted(() => { if (cancelTokenSource) { cancelTokenSource.cancel('组件卸载,取消请求'); } }); </script> <style scoped> /* 移动端适配样式 */ .detail-container { padding: 12px; } .index-card { border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .card-header { font-size: 18px; font-weight: 600; color: #1a1a1a; } .mobile-form { :deep(.el-form-item__label) { font-weight: 500; margin-bottom: 6px; } :deep(.el-input__inner) { height: 44px; border-radius: 8px; } } .mobile-select { width: 100%; :deep(.el-input__inner) { height: 44px; } } /* 按钮区域样式 */ .button-group { display: flex; gap: 12px; margin-top: 16px; } .action-button { flex: 1; height: 46px; font-size: 16px; border-radius: 8px; } /* 移动端响应式调整 */ @media (max-width: 480px) { .button-group { flex-direction: column; gap: 10px; } .action-button { width: 100%; } } </style>
相关推荐





<!doctype html> <html lang="en" dir="ltr" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content="ceosdesigns.sk"> <title>登录</title> </head> <body> <main id="page-content" class="d-flex nm-aic nm-vh-md-100"> 书画展览管理系统 <form th:action="@{/loginUser}" method="post"> 登录 输入您的账户和密码以访问帐户 <label for="username">账户</label> <input type="text" class="form-control" id="username" name="username" tabindex="1" placeholder="请输入有效账户" required> <label for="password"> 密码 </label> <input type="password" class="form-control" tabindex="2" placeholder="请输入密码" id="password" name="password" required> <label for="username">账户</label> <select class="form-select" name="type"> <option value="1" selected>管理员</option> <option value="2">用户</option> </select> <button type="submit" class="btn btn-primary btn-block nm-hvr nm-btn-1"> 登录</button> </form> </main> <script src="login/js/jquery-3.6.0.min.js"></script> <script src="login/js/bootstrap.bundle.min.js"></script> <script src="login/js/script.js"></script> </body> </html>登录页面如何实现的


<?php $show_title="$MSG_LOGIN - $OJ_NAME"; ?>
<?php include("template/$OJ_TEMPLATE/header.php");?>
<style>
.login-container {
background: url('背景图URL') no-repeat center/cover;
min-height: 100vh;
display: flex;
align-items: center;
}
.login-box {
background: rgba(255, 255, 255, 0.95);
padding: 2.5rem;
border-radius: 12px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 420px;
margin: 0 auto;
}
.login-icon {
color: #2185d0 !important;
}
#vcode-img {
height: 42px;
border-radius: 6px;
margin-top: 8px;
cursor: pointer;
border: 1px solid #ddd;
}
</style>
<?php echo $MSG_LOGIN ?>
<form class="ui form" id="login" action="login.php" method="post" onSubmit="return jsMd5();">
<input name="user_id" placeholder="<?php echo $MSG_USER_ID ?>" type="text" id="username" autofocus>
<input name="password" placeholder="<?php echo $MSG_PASSWORD ?>" type="password" id="password">
<?php if($OJ_VCODE){ ?>
<input name="vcode" placeholder="<?php echo $MSG_VCODE ?>" type="text" autocomplete="off">
<?php } ?>
<button type="submit" class="ui fluid large blue submit button"
style="margin-top: 2rem; padding: 14px; font-size: 1.1em;">
<?php echo $MSG_LOGIN ?>
</button>
</form>
<?php if ($OJ_REGISTER){ ?>
或
<?php echo $MSG_REGISTER ?>
<?php } ?>
<script>
// 自动刷新验证码
function refreshVcode() {
$("#vcode-img").attr("src", "vcode.php?" + Math.random());
}
<?php if ($OJ_VCODE) { ?>
$(document).ready(refreshVcode);
<?php } ?>
</script>
<?php include("template/$OJ_TEMPLATE/footer.php");?> 美化页面、固定登录框不要移动、不要更改别的文件、不要影响原来的功能

<template> 欢迎登录 <el-form status-icon ref=“formRef” :rules=“data.rules” :model=“data.form” style=“margin-bottom: 20px;”> <el-form-item prop=“username”> <el-input v-model=“data.form.username” prefix-icon=“User” placeholder=“请输入账号” clearable /> </el-form-item> <el-form-item prop=“password”> <el-input v-model=“data.form.password” prefix-icon=“Lock” placeholder=“请输入密码” show-password clearable /> </el-form-item> {{ role.label }} <el-button @click=“login” type=“primary” class=“login-btn”>登 录</el-button> 还没有账号? 立即注册 </el-form> </template> <script setup> import { reactive, ref } from ‘vue’ import { User, Lock } from ‘@element-plus/icons-vue’ import { ElMessage } from ‘element-plus’ import request from ‘@/utils/request’ import axios from ‘axios’ const roles = [ { label: ‘管理员’, value: ‘ADMIN’ }, { label: ‘教师’, value: ‘TEACHER’ }, { label: ‘学生’, value: ‘STUDENT’ } ] const data = reactive({ form: { role: ‘ADMIN’, username: ‘’, password: ‘’ }, rules: { username: [{ required: true, message: ‘请输入账号’, trigger: ‘blur’ }], password: [{ required: true, message: ‘请输入密码’, trigger: ‘blur’ }] } }) const formRef = ref() const login = () => { formRef.value.validate(async (valid) => { if (!valid) return try { const res = await request.post('/login', data.form) if (res.code === '200') { localStorage.setItem('xm-pro-user', JSON.stringify({ ...res.data, token: res.data.token // 确保token字段存在 })) ElMessage.success('登录成功') // 添加路由跳转容错处理 setTimeout(() => { if (res.data.role === 'ADMIN') { window.location.href = '/' } else { window.location.href = '/front/home' } }, 500) } } catch (error) { ElMessage.error(res.msg) } }) } </script> <template v-if=“!data.user”> <router-link to=“/front/home” class=“nav-item”>首页</router-link> <router-link to=“/courses” class=“nav-item”>视频课程</router-link> <router-link to=“/live” class=“nav-item”>直播课程</router-link> </template> <router-link to=“/login” class=“auth-link”>登录</router-link> | <router-link to=“/register” class=“auth-link”>注册</router-link> 为什么点击登录的时候页面一点反应都没有,也登录不成功,浏览器报错POST http://localhost:8080/login net::ERR_FAILEDUncaught (in promise) ReferenceError: res is not defined





<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>硬件运维系统 - 报告管理</title> </head> <body> 报告管理 <input type="text" id="search-report" placeholder="搜索报告名称/类型"> <button class="btn" id="search-btn">搜索</button> <button class="btn" id="sort-by-date">按日期排序</button> <button class="btn btn-download" id="download-all">下载全部报告</button> <button class="btn" id="add-report">新增报告</button> 新增报告 × <form id="report-form"> <input type="hidden" id="report-id"> <label for="report-name">报告名称</label> <input type="text" id="report-name" required> <label for="report-type">报告类型</label> <select id="report-type" required> <option value="硬件故障处理报告">硬件故障处理报告</option> <option value="软件运维报告">软件运维报告</option> <option value="设备健康度报告">设备健康度报告</option> <option value="产线运行分析报告">产线运行分析报告</option> <option value="硬件日志采集报告">硬件选择 - 获取指定时间段的日志</option> </select> <label for="log-start-date">日志开始日期</label> <input type="date" id="log-start-date" required> <label for="log-end-date" style="margin-top: 10px;">日志结束日期</label> <input type="date" id="log-end-date" required> <label for="report-date">报告生成日期</label> <input type="date" id="report-date" required> <label for="report-content">报告内容</label> 请根据报告类型填写内容... <textarea id="report-content" required></textarea> <button type="button" class="btn" id="cancel-btn">取消</button> <button type="submit" class="btn">保存</button> </form> <script src="style/js/jquery.min.js"></script> <script> // 检查登录状态 if (localStorage.getItem('isLogin') !== '1') { window.location.href = 'login.html'; } // 初始化报告数据和硬件日志数据 let reports = []; let hardwareLogs = []; // DOM 元素缓存 const $reportList = $('#report-list'); const $reportModal = $('#report-modal'); const $modalTitle = $('#modal-title'); const $reportForm = $('#report-form'); const $reportId = $('#report-id'); const $reportName = $('#report-name'); const $reportType = $('#report-type'); const $reportDate = $('#report-date'); const $reportContent = $('#report-content'); const $addReportBtn = $('#add-report'); const $cancelBtn = $('#cancel-btn'); const $closeBtn = $('.close'); const $searchBtn = $('#search-btn'); const $searchInput = $('#search-report'); const $sortByDateBtn = $('#sort-by-date'); const $downloadAllBtn = $('#download-all'); const $logTimeRange = $('.log-time-range'); const $contentDesc = $('#content-desc'); // 报告类型模板映射 const typeTemplates = { '硬件故障处理报告': 1. 故障现象: 2. 故障排查过程: 3. 处理方案: 4. 处理结果: 5. 预防建议:, '软件运维报告': 1. 运维内容: 2. 操作过程: 3. 运行状态: 4. 遗留问题: 5. 后续计划:, '设备健康度报告': 1. 设备状态: 2. 检查项目: 3. 异常项: 4. 维护建议: 5. 预测分析:, '产线运行分析报告': 1. 生产数据: 2. 设备表现: 3. 瓶颈分析: 4. 改进措施: 5. 提升建议:, '硬件日志采集报告': ### 日志采集说明 - 采集时间段:{startDate} 至 {endDate} - 涉及设备:自动从日志中提取 - 异常日志数量:{errorCount} ### 关键日志摘要 {logSummary} }; // 从API加载报告数据 function loadReports() { $.ajax({ url: 'api/reports.php', method: 'GET', dataType: 'json', success: function (data) { reports = data || []; renderReports(reports); }, error: function (xhr, status, error) { console.error('加载报告失败:', error); $reportList.html('加载报告数据失败,请稍后重试'); } }); } // 加载硬件日志数据 function loadHardwareLogs() { $.getJSON('data/hardware_logs.json', (data) => { hardwareLogs = data.logs || []; console.log('硬件日志加载成功'); }).fail((xhr, status, error) => { console.error('加载硬件日志失败:', error); hardwareLogs = []; }); } // 渲染报告列表 function renderReports(reportData) { $reportList.empty(); // 解绑之前的事件处理器,避免重复绑定 $reportList.off('click', '.edit-btn'); $reportList.off('click', '.delete-btn'); $reportList.off('click', '.download-btn'); if (reportData.length === 0) { $reportList.html('暂无报告数据,请点击"新增报告"创建'); return; } reportData.forEach(report => { const $card = $( ${report.name} ${report.type} | 生成日期:${report.date} <button class="action-btn download-btn">下载</button> <button class="action-btn edit-btn">编辑</button> <button class="action-btn delete-btn">删除</button> ); $reportList.append($card); }); // 绑定事件 $reportList.on('click', '.edit-btn', function () { const reportId = $(this).closest('.report-card').data('id'); editReport(reportId); }); $reportList.on('click', '.delete-btn', function () { const reportId = $(this).closest('.report-card').data('id'); deleteReport(reportId); }); $reportList.on('click', '.download-btn', function () { const reportId = $(this).closest('.report-card').data('id'); downloadReport(reportId); }); } // 打开模态框 function openModal(isEdit = false, report = null) { $reportForm[0].reset(); $logTimeRange.hide(); $reportContent.val(''); if (isEdit && report) { $modalTitle.text('编辑报告'); $reportId.val(report.id); $reportName.val(report.name); $reportType.val(report.type); $reportDate.val(report.date); $reportContent.val(report.content); if (report.type === '硬件日志采集报告') { $logTimeRange.show(); $('#log-start-date').val(report.logStartDate || ''); $('#log-end-date').val(report.logEndDate || ''); } } else { $modalTitle.text('新增报告'); $reportId.val(''); $reportDate.val(new Date().toISOString().split('T')[0]); } $reportModal.show(); } // 关闭模态框 function closeModal() { $reportModal.hide(); } // 编辑报告 function editReport(id) { console.log('编辑报告:', reports); console.log('报告ID:', id); const stringId = String(id); const report = reports.find(r => r.id === stringId); console.log('编辑报告:', report); // console.log(r.id); if (report) { openModal(true, report); } else { alert('未找到该报告'); loadReports(); } } // 删除报告 function deleteReport(id) { const stringId = String(id); const report = reports.find(r => r.id === stringId); if (!report) { alert('未找到该报告'); loadReports(); return; } if (confirm(确定要删除"${report.name}"这份报告吗?删除后无法恢复!)) { $.ajax({ url: 'api/reports.php', method: 'DELETE', contentType: 'application/json', data: JSON.stringify({ id: id }), dataType: 'json', success: function (response) { if (response.success) { loadReports(); // 重新加载数据 } else { alert('删除失败:' + (response.message || '未知错误')); } }, error: function (xhr, status, error) { console.error('删除报告失败:', error); alert('删除报告失败,请检查网络连接'); } }); } } // 下载单个报告 function downloadReport(id) { const report = reports.find(r => r.id === id); if (!report) return; let content = 报告名称:${report.name} 报告类型:${report.type} 生成日期:${report.date} 报告内容: ${report.content} .trim(); if (report.type === '硬件日志采集报告' && report.attachments && report.attachments.length) { content += \n\n=== 日志附件 ===\n; report.attachments.forEach(attach => { content += \n【附件:${attach.filename}】\n${attach.content}\n; }); } const blob = new Blob([content], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = $('').attr({ href: url, download: ${report.name.replace(/[\/:*?"<>|]/g, '-')}.txt }); $('body').append(a); a[0].click(); a.remove(); URL.revokeObjectURL(url); } // 下载全部报告 function downloadAllReports() { if (reports.length === 0) { alert('没有报告可下载'); return; } let allContent = '=== 所有报告汇总 ===\n\n'; reports.forEach((report, idx) => { allContent += 【报告 ${idx + 1}】\n; allContent += 名称:${report.name}\n类型:${report.type}\n日期:${report.date}\n\n; allContent += 内容:\n${report.content}\n\n; if (report.type === '硬件日志采集报告' && report.attachments && report.attachments.length) { allContent += === 日志附件 ===\n; report.attachments.forEach(attach => { allContent += \n【附件:${attach.filename}】\n${attach.content}\n; }); } allContent += '========================================\n\n'; }); const blob = new Blob([allContent], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = $('').attr({ href: url, download: 所有报告汇总_${new Date().toISOString().split('T')[0]}.txt }); $('body').append(a); a[0].click(); a.remove(); URL.revokeObjectURL(url); } // 保存报告 $reportForm.on('submit', function (e) { e.preventDefault(); const formData = { id: $reportId.val(), name: $reportName.val(), type: $reportType.val(), date: $reportDate.val(), content: $reportContent.val(), attachments: [] }; if (formData.type === '硬件日志采集报告') { const startDate = $('#log-start-date').val(); const endDate = $('#log-end-date').val(); formData.logStartDate = startDate; formData.logEndDate = endDate; const filteredLogs = hardwareLogs.filter(log => { const logTime = new Date(log.timestamp); const start = new Date(startDate); const end = new Date(endDate); return logTime >= start && logTime <= end; }); if (filteredLogs.length > 0) { const errorCount = filteredLogs.filter(log => log.level === 'ERROR').length; const logSummary = filteredLogs.map(log => [${log.timestamp}] [${log.device}] [${log.level}]:${log.content} ).join('\n'); formData.content = typeTemplates['硬件日志采集报告'] .replace('{startDate}', startDate) .replace('{endDate}', endDate) .replace('{errorCount}', errorCount) .replace('{logSummary}', logSummary); formData.attachments.push({ filename: hardware_logs_${startDate}_${endDate}.txt, content: filteredLogs.map(log => ${log.timestamp}\n${log.device}\n${log.level}\n${log.content}\n-----\n ).join('') }); } else { formData.content = '未找到指定时间段的日志数据'; } } const method = formData.id ? 'PUT' : 'POST'; $.ajax({ url: 'api/reports.php', method: method, contentType: 'application/json', data: JSON.stringify(formData), dataType: 'json', success: function (response) { if (response.success) { loadReports(); closeModal(); } else { alert('保存失败:' + (response.message || '未知错误')); } }, error: function (xhr, status, error) { console.error('保存报告失败:', error); alert('保存报告失败,请检查网络连接'); } }); }); // 搜索报告 function handleSearch() { const keyword = $searchInput.val().toLowerCase(); const filtered = reports.filter(report => report.name.toLowerCase().includes(keyword) || report.type.toLowerCase().includes(keyword) ); renderReports(filtered); } // 按日期排序 function sortReportsByDate() { const sorted = [...reports].sort((a, b) => new Date(b.date) - new Date(a.date) ); renderReports(sorted); } // 事件绑定 function bindEvents() { // 报告类型切换 // / 修改报告类型切换事件 $reportType.on('change', function () { const type = $(this).val(); const $startDate = $('#log-start-date'); const $endDate = $('#log-end-date'); $logTimeRange.hide(); $contentDesc.text('请根据报告类型填写内容...'); if (type === '硬件日志采集报告') { $logTimeRange.show(); $contentDesc.text('选择时间段后将自动生成日志摘要'); $reportContent.val(''); // 仅在日志类型下添加必填属性 $startDate.attr('required', true); $endDate.attr('required', true); } else { $reportContent.val(typeTemplates[type] || ''); // 其他类型下移除必填属性 $startDate.removeAttr('required'); $endDate.removeAttr('required'); } }); // 新增报告 $addReportBtn.on('click', () => openModal()); // 关闭模态框 $closeBtn.on('click', closeModal); $cancelBtn.on('click', closeModal); // 点击模态框外部关闭 $(window).on('click', (e) => { if ($(e.target).is($reportModal)) closeModal(); }); // 搜索 $searchBtn.on('click', handleSearch); $searchInput.on('keypress', (e) => { if (e.key === 'Enter') handleSearch(); }); // 排序 $sortByDateBtn.on('click', sortReportsByDate); // 下载全部 $downloadAllBtn.on('click', downloadAllReports); } // 初始化 function init() { bindEvents(); loadHardwareLogs(); loadReports(); } // 页面加载完成后初始化 $(document).ready(init); </script> </body> </html> 优化代码.让拟态窗更加好看


<template> 欢迎登录 <el-form ref=“formRef” :rules=“data.rules” :model=“data.form” style=“margin-left: 35px;margin-bottom: 50px;”> <el-form-item prop=“username”> <input type=“text” v-model=“data.form.username” autocomplete=“off” prefix-icon=“Uaer” placeholder=“请输入账号” required </el-form-item> <el-form-item prop=“password”> <input show-password type=“password” v-model=“data.form.password” placeholder=“请输入密码” required </el-form-item> <el-form-item prop=“role”> </el-form-item> <el-button @click=“login” type=“primary” style=“color: black;width: 91%;margin-top: 3px;margin-bottom: 10px;”>登 录</el-button> 还没有账号? 请注册 </el-form> </template> <script setup> import { reactive } from ‘vue’; import { ref } from ‘vue’ import { User } from ‘@element-plus/icons-vue’; import request from ‘@/utils/request’; import { ElMessage } from ‘element-plus’; const data=reactive({ form:{ role:‘admin’ }, rules:{ username:[{ required:true,message:‘请输入账号’,trigger:‘blur’ }], password:[{ required:true, message:‘请输入密码’,trigger:‘blur’ }], }, user: null }) const formRef=ref() const username = ref(‘’) const password = ref(‘’) const login = () => { // 处理登录逻辑 formRef.value.validate((valid)=>{ if(valid){ request.post(‘/login’,data.form).then(res=>{ if(res.code===‘200’){ //存储后台返回的用户数据信息this.$set(this.data, ‘user’, response.data.user) localStorage.setItem(‘xm-pro-user’,JSON.stringify(res.data))//把json对象转换成json字符串存储 ElMessage.success(‘登录成功’) setTimeout(()=>{ location.href=‘/manager/home’ },500) } else{ ElMessage.error(res.msg) } })}})} </script> <style scoped> .background{ background: url(“@/assets/bg.png”); width:100%; height:100%; /**宽高100%是为了图片铺满屏幕 */ position: absolute; background-size: 100% 100%; } .login-box{ width: 50%; height: 100%; display: flex; align-items: center; position: absolute; } .blur-box { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 16px; padding: 40px; width: 400px; height: 270px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); position: relative; align-items: center; } h2 { color: rgba(255, 255, 255, 0.9); text-align: center; margin-bottom: 30px; } .input-group input { width: 80%; padding: 12px 20px; margin: 8px 0; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 8px; color: #0c0b0b; transition: all 0.3s ease; } .input-group input:focus { outline: none; border-color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.2); } button { width: 100%; padding: 12px; margin-top: 20px; background: #0742b1(2, 66, 139, 0.2); border: 1px solid rgba(160, 99, 99, 0.3); color: #43bbef; border-radius: 8px; cursor: pointer; transition: all 0.3s ease; } button:hover { background: rgba(255, 255, 255, 0.3); } </style>修改这个登录的前端页面,要求样式不要改变还是半透明磨砂,输入账号框里加一个用户图标,密码框里加一个密码图标.再在密码框下面给出多角色权限登录,其中角色有管理员,老师和学生.给出小圆圈的样式选择角色,要求整体设计美观.要求角色选择在同一行上面而且选择时按钮的颜色要小清新的蓝色,登录框整体要在页面正中间,而且整体登录框占整个页面的大小也要十分合适.在给出的代码上作出修改之后再给我,需要完整代码




