feat: 添加美观的系统首页展示
This commit is contained in:
@@ -15,6 +15,8 @@ from rest_framework_simplejwt.views import (
|
||||
TokenRefreshView,
|
||||
)
|
||||
|
||||
from device_management.views import home_page
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
title="视频主设备管理系统 API",
|
||||
@@ -29,6 +31,7 @@ schema_view = get_schema_view(
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path('', home_page, name='home'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/', include('device_management.urls')),
|
||||
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
|
||||
249
device_management/templates/device_management/index.html
Normal file
249
device_management/templates/device_management/index.html
Normal file
@@ -0,0 +1,249 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>视频主设备管理系统</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<style>
|
||||
.gradient-bg {
|
||||
background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 50%, #1e3a5f 100%);
|
||||
}
|
||||
.card-hover:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.15);
|
||||
}
|
||||
.pulse-dot {
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-gray-50 min-h-screen">
|
||||
<!-- Header -->
|
||||
<header class="gradient-bg text-white shadow-lg">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="w-14 h-14 bg-white/20 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold tracking-tight">视频主设备管理系统</h1>
|
||||
<p class="text-blue-200 text-sm mt-1">Device Management System · RESTful API Service</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="pulse-dot w-2 h-2 bg-green-400 rounded-full"></span>
|
||||
<span class="text-green-300 text-sm font-medium">服务运行中</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
|
||||
<!-- Stats Overview -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-5 mb-10">
|
||||
<div class="bg-white rounded-2xl p-6 shadow-sm border border-gray-100 card-hover transition-all duration-300">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-blue-600 bg-blue-50 px-2.5 py-1 rounded-full">核心</span>
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-1">设备管理</h3>
|
||||
<p class="text-gray-500 text-sm">全生命周期设备资产库</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl p-6 shadow-sm border border-gray-100 card-hover transition-all duration-300">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-green-600 bg-green-50 px-2.5 py-1 rounded-full">网络</span>
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-1">IP/序列号管理</h3>
|
||||
<p class="text-gray-500 text-sm">唯一性校验防止冲突</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl p-6 shadow-sm border border-gray-100 card-hover transition-all duration-300">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-12 h-12 bg-orange-100 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-6 h-6 text-orange-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-orange-600 bg-orange-50 px-2.5 py-1 rounded-full">运维</span>
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-1">维修/巡检追踪</h3>
|
||||
<p class="text-gray-500 text-sm">历史可追溯保修预警</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl p-6 shadow-sm border border-gray-100 card-hover transition-all duration-300">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
|
||||
<svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-purple-600 bg-purple-50 px-2.5 py-1 rounded-full">数据</span>
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-1">Excel导入导出</h3>
|
||||
<p class="text-gray-500 text-sm">批量数据高效管理</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Links -->
|
||||
<div class="mb-10">
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-5">快捷入口</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<a href="/swagger/" class="group bg-gradient-to-br from-blue-500 to-blue-600 rounded-2xl p-6 text-white card-hover transition-all duration-300 shadow-lg shadow-blue-200">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-14 h-14 bg-white/20 rounded-xl flex items-center justify-center group-hover:bg-white/30 transition-colors">
|
||||
<svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<svg class="w-6 h-6 opacity-0 group-hover:opacity-100 transition-opacity transform group-hover:translate-x-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8l4 4m0 0l-4 4m4-4H3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-bold mb-1">Swagger API 文档</h3>
|
||||
<p class="text-blue-100 text-sm">交互式接口调试,支持在线测试</p>
|
||||
</a>
|
||||
|
||||
<a href="/redoc/" class="group bg-gradient-to-br from-green-500 to-green-600 rounded-2xl p-6 text-white card-hover transition-all duration-300 shadow-lg shadow-green-200">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-14 h-14 bg-white/20 rounded-xl flex items-center justify-center group-hover:bg-white/30 transition-colors">
|
||||
<svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<svg class="w-6 h-6 opacity-0 group-hover:opacity-100 transition-opacity transform group-hover:translate-x-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8l4 4m0 0l-4 4m4-4H3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-bold mb-1">Redoc API 文档</h3>
|
||||
<p class="text-green-100 text-sm">美观的文档展示,适合阅读浏览</p>
|
||||
</a>
|
||||
|
||||
<a href="/admin/" class="group bg-gradient-to-br from-gray-700 to-gray-800 rounded-2xl p-6 text-white card-hover transition-all duration-300 shadow-lg shadow-gray-200">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="w-14 h-14 bg-white/20 rounded-xl flex items-center justify-center group-hover:bg-white/30 transition-colors">
|
||||
<svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/>
|
||||
</svg>
|
||||
</div>
|
||||
<svg class="w-6 h-6 opacity-0 group-hover:opacity-100 transition-opacity transform group-hover:translate-x-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8l4 4m0 0l-4 4m4-4H3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-xl font-bold mb-1">Django Admin</h3>
|
||||
<p class="text-gray-300 text-sm">后台管理界面,数据可视化管理</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tech Stack & API Info -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Tech Stack -->
|
||||
<div class="bg-white rounded-2xl p-7 shadow-sm border border-gray-100">
|
||||
<h3 class="text-lg font-bold text-gray-800 mb-5 flex items-center">
|
||||
<span class="w-1.5 h-6 bg-blue-500 rounded-full mr-3"></span>
|
||||
技术栈
|
||||
</h3>
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-xl hover:bg-gray-100 transition-colors">
|
||||
<span class="text-gray-700 font-medium">后端框架</span>
|
||||
<span class="text-sm bg-white px-3 py-1.5 rounded-lg text-gray-600 shadow-sm">Django 4.2 + DRF 3.15</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-xl hover:bg-gray-100 transition-colors">
|
||||
<span class="text-gray-700 font-medium">身份认证</span>
|
||||
<span class="text-sm bg-white px-3 py-1.5 rounded-lg text-gray-600 shadow-sm">JWT Token + Session</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-xl hover:bg-gray-100 transition-colors">
|
||||
<span class="text-gray-700 font-medium">图片处理</span>
|
||||
<span class="text-sm bg-white px-3 py-1.5 rounded-lg text-gray-600 shadow-sm">Pillow (自动缩略图)</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-xl hover:bg-gray-100 transition-colors">
|
||||
<span class="text-gray-700 font-medium">Excel处理</span>
|
||||
<span class="text-sm bg-white px-3 py-1.5 rounded-lg text-gray-600 shadow-sm">openpyxl + pandas</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-xl hover:bg-gray-100 transition-colors">
|
||||
<span class="text-gray-700 font-medium">日志系统</span>
|
||||
<span class="text-sm bg-white px-3 py-1.5 rounded-lg text-gray-600 shadow-sm">loguru</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- API Endpoints -->
|
||||
<div class="bg-white rounded-2xl p-7 shadow-sm border border-gray-100">
|
||||
<h3 class="text-lg font-bold text-gray-800 mb-5 flex items-center">
|
||||
<span class="w-1.5 h-6 bg-green-500 rounded-full mr-3"></span>
|
||||
API 端点
|
||||
</h3>
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-green-100 text-green-700 px-2 py-1 rounded">GET</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/devices/</code>
|
||||
<span class="text-xs text-gray-500">设备列表</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-blue-100 text-blue-700 px-2 py-1 rounded">POST</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/devices/</code>
|
||||
<span class="text-xs text-gray-500">创建设备</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-green-100 text-green-700 px-2 py-1 rounded">GET</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/devices/{id}/</code>
|
||||
<span class="text-xs text-gray-500">设备详情</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-green-100 text-green-700 px-2 py-1 rounded">GET</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/devices/export_excel/</code>
|
||||
<span class="text-xs text-gray-500">导出Excel</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-orange-100 text-orange-700 px-2 py-1 rounded">POST</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/devices/import_excel/</code>
|
||||
<span class="text-xs text-gray-500">导入Excel</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<span class="text-xs font-bold bg-orange-100 text-orange-700 px-2 py-1 rounded">POST</span>
|
||||
<code class="text-sm bg-gray-900 text-green-400 px-3 py-1.5 rounded-lg flex-1">/api/token/</code>
|
||||
<span class="text-xs text-gray-500">JWT认证</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="border-t border-gray-200 mt-16">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div class="flex flex-col md:flex-row items-center justify-between text-sm text-gray-500">
|
||||
<p>© 2026 视频主设备管理系统 · Django REST Framework</p>
|
||||
<p class="mt-2 md:mt-0">
|
||||
<span class="text-gray-400">数据库模型:</span>
|
||||
<span class="font-medium text-gray-700">Device</span>,
|
||||
<span class="font-medium text-gray-700">DeviceSerial</span>,
|
||||
<span class="font-medium text-gray-700">DeviceIP</span>,
|
||||
<span class="font-medium text-gray-700">MaintenanceRecord</span>,
|
||||
<span class="font-medium text-gray-700">DeviceAttachment</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
from datetime import date
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django_filters import rest_framework as filters
|
||||
from rest_framework import viewsets, status, parsers, renderers
|
||||
from rest_framework.decorators import action, api_view, parser_classes
|
||||
@@ -12,6 +12,10 @@ from openpyxl.styles import Font
|
||||
import pandas as pd
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def home_page(request):
|
||||
return render(request, 'device_management/index.html')
|
||||
|
||||
from .models import (
|
||||
Device, DeviceSerial, DeviceIP, MaintenanceRecord, DeviceAttachment
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user