Compare commits
10 Commits
9fee94f90f
...
dev_202510
| Author | SHA1 | Date | |
|---|---|---|---|
| f6bb392d49 | |||
| 53d3a88a1c | |||
| 577b37b768 | |||
| e264cb15b9 | |||
| c18366836f | |||
| 816396d9c0 | |||
| 4c66e875cf | |||
| 0df7f645a6 | |||
| ed2b7bfba6 | |||
| 6ab0508e8c |
@@ -23,12 +23,18 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/**")
|
||||
// 排除登录、注册、发送验证码接口
|
||||
.excludePathPatterns("/user/login", "/user/register", "/user/sendCode")
|
||||
// 排除后台管理登录接口
|
||||
.excludePathPatterns("/sys/user/login")
|
||||
// 排除反馈接口(支持匿名提交)
|
||||
.excludePathPatterns("/feedback", "/feedback/**")
|
||||
// 排除教程接口(支持匿名查询)
|
||||
.excludePathPatterns("/tutorial", "/tutorial/**")
|
||||
// 排除固件查询接口(不需要登录)
|
||||
.excludePathPatterns("/firmware/**")
|
||||
// 排除静态资源
|
||||
.excludePathPatterns("/", "/index.html", "/*.html", "/*.css", "/*.js", "/*.ico", "/static/**")
|
||||
// 排除后台管理静态资源
|
||||
.excludePathPatterns("/admin/**")
|
||||
// 排除 Druid 监控
|
||||
.excludePathPatterns("/druid/**")
|
||||
// 排除错误页面
|
||||
|
||||
@@ -23,68 +23,6 @@ public class FirmwareController {
|
||||
this.firmwareService = firmwareService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增固件
|
||||
*/
|
||||
@PostMapping
|
||||
public Result<String> add(@RequestBody Firmware firmware) {
|
||||
try {
|
||||
// 检查固件名称是否已存在
|
||||
Firmware existFirmware = firmwareService.getByFirmwareName(firmware.getFirmwareName());
|
||||
if (existFirmware != null) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.name.exists"));
|
||||
}
|
||||
|
||||
boolean success = firmwareService.save(firmware);
|
||||
if (success) {
|
||||
return Result.success(I18nUtil.getMessage("firmware.add.success"));
|
||||
}
|
||||
return Result.error(I18nUtil.getMessage("firmware.add.failed"));
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除固件
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<String> delete(@PathVariable Long id) {
|
||||
try {
|
||||
boolean success = firmwareService.removeById(id);
|
||||
if (success) {
|
||||
return Result.success(I18nUtil.getMessage("firmware.delete.success"));
|
||||
}
|
||||
return Result.error(I18nUtil.getMessage("firmware.delete.failed"));
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新固件
|
||||
*/
|
||||
@PutMapping
|
||||
public Result<String> update(@RequestBody Firmware firmware) {
|
||||
try {
|
||||
// 检查固件名称是否与其他固件重复
|
||||
if (StringUtils.hasText(firmware.getFirmwareName())) {
|
||||
Firmware existFirmware = firmwareService.getByFirmwareName(firmware.getFirmwareName());
|
||||
if (existFirmware != null && !existFirmware.getId().equals(firmware.getId())) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.name.exists"));
|
||||
}
|
||||
}
|
||||
|
||||
boolean success = firmwareService.updateById(firmware);
|
||||
if (success) {
|
||||
return Result.success(I18nUtil.getMessage("firmware.update.success"));
|
||||
}
|
||||
return Result.error(I18nUtil.getMessage("firmware.update.failed"));
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询固件
|
||||
*/
|
||||
@@ -140,4 +78,24 @@ public class FirmwareController {
|
||||
java.util.List<Firmware> list = firmwareService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询固件版本
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
*/
|
||||
@GetMapping("/type/{firmwareType}")
|
||||
public Result<java.util.List<Firmware>> listByType(@PathVariable Integer firmwareType) {
|
||||
if (firmwareType == null) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.type.required"));
|
||||
}
|
||||
|
||||
QueryWrapper<Firmware> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("firmware_type", firmwareType);
|
||||
// 按版本号或创建时间倒序排列,最新版本在前
|
||||
wrapper.orderByDesc("create_time");
|
||||
|
||||
java.util.List<Firmware> list = firmwareService.list(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.corewing.app.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.dto.SysLoginRequest;
|
||||
import com.corewing.app.entity.SysUser;
|
||||
import com.corewing.app.service.SysUserService;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import com.corewing.app.util.IpUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台管理用户 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/user")
|
||||
public class SysUserController {
|
||||
|
||||
private final SysUserService sysUserService;
|
||||
|
||||
public SysUserController(SysUserService sysUserService) {
|
||||
this.sysUserService = sysUserService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台管理登录
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result<Map<String, Object>> login(@RequestBody SysLoginRequest request, HttpServletRequest httpRequest) {
|
||||
try {
|
||||
// 获取登录IP
|
||||
String loginIp = IpUtil.getClientIp(httpRequest);
|
||||
|
||||
// 执行登录
|
||||
String token = sysUserService.login(request.getUsername(), request.getPassword(), loginIp);
|
||||
|
||||
// 查询用户信息
|
||||
SysUser user = sysUserService.getByUsername(request.getUsername());
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("token", token);
|
||||
data.put("userId", user.getId());
|
||||
data.put("username", user.getUsername());
|
||||
data.put("realName", user.getRealName());
|
||||
|
||||
return Result.success(I18nUtil.getMessage("user.login.success"), data);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台管理登出
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public Result<String> logout() {
|
||||
StpUtil.logout();
|
||||
return Result.success(I18nUtil.getMessage("user.logout.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户信息
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public Result<SysUser> getUserInfo() {
|
||||
Long userId = StpUtil.getLoginIdAsLong();
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
// 隐藏密码
|
||||
user.setPassword(null);
|
||||
return Result.success(user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.corewing.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.entity.Tutorial;
|
||||
import com.corewing.app.entity.TutorialCategory;
|
||||
import com.corewing.app.service.TutorialCategoryService;
|
||||
import com.corewing.app.service.TutorialService;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 教程接口
|
||||
*/
|
||||
@RequestMapping("/tutorial")
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class TutorialController {
|
||||
|
||||
private final TutorialService tutorialService;
|
||||
private final TutorialCategoryService tutorialCategoryService;
|
||||
|
||||
public TutorialController(TutorialService tutorialService, TutorialCategoryService tutorialCategoryService) {
|
||||
this.tutorialService = tutorialService;
|
||||
this.tutorialCategoryService = tutorialCategoryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类查询列表
|
||||
*
|
||||
* @param firstStatus 置首状态(选填)
|
||||
*
|
||||
*/
|
||||
@GetMapping("/category")
|
||||
public Result<List<TutorialCategory>> category(
|
||||
@RequestParam(required = false, defaultValue = "0") Integer firstStatus
|
||||
) {
|
||||
log.info("当前语言环境:{}", I18nUtil.getCurrentLocale().getLanguage());
|
||||
LambdaQueryWrapper<TutorialCategory> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(firstStatus != 0, TutorialCategory::getFirstStatus, firstStatus);
|
||||
wrapper.eq(TutorialCategory::getLang, I18nUtil.getCurrentLocale().getLanguage());
|
||||
List<TutorialCategory> list = tutorialCategoryService.list(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询教程列表
|
||||
*
|
||||
* @param current 当前页码
|
||||
* @param size 每页数量
|
||||
* @param categoryId 分类ID(选填)
|
||||
* @param tutorialTitle 教程标题(选填)
|
||||
*
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result<IPage<Tutorial>> getPageList(
|
||||
@RequestParam(defaultValue = "1") Long current,
|
||||
@RequestParam(defaultValue = "10") Long size,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer categoryId,
|
||||
@RequestParam(required = false) String tutorialTitle) {
|
||||
try {
|
||||
Page<Tutorial> page = new Page<>(current, size);
|
||||
IPage<Tutorial> pageResult = tutorialService.pageList(page, categoryId, tutorialTitle, I18nUtil.getCurrentLocale().getLanguage());
|
||||
return Result.success(pageResult);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
src/main/java/com/corewing/app/dto/SysLoginRequest.java
Normal file
20
src/main/java/com/corewing/app/dto/SysLoginRequest.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.corewing.app.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 后台管理登录请求参数
|
||||
*/
|
||||
@Data
|
||||
public class SysLoginRequest {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class Firmware implements Serializable {
|
||||
/**
|
||||
* 固件类型
|
||||
*/
|
||||
private String firmwareType;
|
||||
private Integer firmwareType;
|
||||
|
||||
/**
|
||||
* 固件下载地址
|
||||
|
||||
89
src/main/java/com/corewing/app/entity/SysUser.java
Normal file
89
src/main/java/com/corewing/app/entity/SysUser.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 后台管理用户实体类
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user")
|
||||
public class SysUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码(MD5加密)
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 头像URL
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private LocalDateTime loginTime;
|
||||
|
||||
/**
|
||||
* 状态:0-禁用 1-启用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
73
src/main/java/com/corewing/app/entity/Tutorial.java
Normal file
73
src/main/java/com/corewing/app/entity/Tutorial.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 教程
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_tutorial")
|
||||
public class Tutorial implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 教程id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 教程标题
|
||||
*/
|
||||
private String tutorialTitle;
|
||||
|
||||
/**
|
||||
* 教程描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 教程详情
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 查看次数
|
||||
*/
|
||||
private Integer viewCount;
|
||||
|
||||
/**
|
||||
* 推荐状态:0不推荐,1推荐
|
||||
*/
|
||||
private Integer recommendStatus;
|
||||
|
||||
/**
|
||||
* 状态:1正常,2关闭
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 语言:中文zh,英文:en
|
||||
*/
|
||||
private String lang;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
70
src/main/java/com/corewing/app/entity/TutorialCategory.java
Normal file
70
src/main/java/com/corewing/app/entity/TutorialCategory.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 教程分类
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_tutorial_category")
|
||||
public class TutorialCategory implements Serializable {
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryTitle;
|
||||
|
||||
/**
|
||||
* 分类描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 类别:category分类,tag标签
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 置首页:0不置首,1置首页
|
||||
*/
|
||||
private Integer firstStatus;
|
||||
|
||||
/**
|
||||
* 状态:1正常,2关闭
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 语言:中文zh,英文:en
|
||||
*/
|
||||
private String lang;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 教程与分类关系实体
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_tutorial_category_relation")
|
||||
public class TutorialCategoryRelation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 教程id
|
||||
*/
|
||||
private Long TutorialId;
|
||||
|
||||
/**
|
||||
* 教程分类id
|
||||
*/
|
||||
private Long CategoryId;
|
||||
|
||||
}
|
||||
13
src/main/java/com/corewing/app/mapper/SysUserMapper.java
Normal file
13
src/main/java/com/corewing/app/mapper/SysUserMapper.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 后台管理用户 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.TutorialCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 教程分类 Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface TutorialCategoryMapper extends BaseMapper<TutorialCategory> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.TutorialCategoryRelation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 教程与教程分类关系Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface TutorialCategoryRelationMapper extends BaseMapper<TutorialCategoryRelation> {
|
||||
}
|
||||
17
src/main/java/com/corewing/app/mapper/TutorialMapper.java
Normal file
17
src/main/java/com/corewing/app/mapper/TutorialMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.corewing.app.entity.Tutorial;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 教程 Mapper 接口
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface TutorialMapper extends BaseMapper<Tutorial> {
|
||||
|
||||
Page<Tutorial> pageList(Page<Tutorial> page, @Param("categoryId") int categoryId, @Param("tutorialTitle") String tutorialTitle, @Param("lang") String lang);
|
||||
}
|
||||
36
src/main/java/com/corewing/app/service/SysUserService.java
Normal file
36
src/main/java/com/corewing/app/service/SysUserService.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.SysUser;
|
||||
|
||||
/**
|
||||
* 后台管理用户 Service 接口
|
||||
*/
|
||||
public interface SysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户信息
|
||||
*/
|
||||
SysUser getByUsername(String username);
|
||||
|
||||
/**
|
||||
* 后台用户登录
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @param loginIp 登录IP
|
||||
* @return token
|
||||
*/
|
||||
String login(String username, String password, String loginIp);
|
||||
|
||||
/**
|
||||
* 更新登录信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param loginIp 登录IP
|
||||
*/
|
||||
void updateLoginInfo(Long userId, String loginIp);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.TutorialCategoryRelation;
|
||||
|
||||
public interface TutorialCategoryRelationService extends IService<TutorialCategoryRelation> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.TutorialCategory;
|
||||
|
||||
public interface TutorialCategoryService extends IService<TutorialCategory> {
|
||||
}
|
||||
10
src/main/java/com/corewing/app/service/TutorialService.java
Normal file
10
src/main/java/com/corewing/app/service/TutorialService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.Tutorial;
|
||||
|
||||
public interface TutorialService extends IService<Tutorial> {
|
||||
IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.SysUser;
|
||||
import com.corewing.app.mapper.SysUserMapper;
|
||||
import com.corewing.app.service.SysUserService;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 后台管理用户 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
|
||||
|
||||
@Override
|
||||
public SysUser getByUsername(String username) {
|
||||
if (!StringUtils.hasText(username)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysUser::getUsername, username);
|
||||
return this.getOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login(String username, String password, String loginIp) {
|
||||
// 查询用户
|
||||
SysUser user = getByUsername(username);
|
||||
if (user == null) {
|
||||
throw new RuntimeException(I18nUtil.getMessage("error.user.not.found"));
|
||||
}
|
||||
|
||||
// 验证密码(MD5加密)
|
||||
String encryptPassword = DigestUtils.md5DigestAsHex(password.getBytes(StandardCharsets.UTF_8));
|
||||
System.out.println(encryptPassword);
|
||||
if (!encryptPassword.equalsIgnoreCase(user.getPassword())) {
|
||||
throw new RuntimeException(I18nUtil.getMessage("error.password.incorrect"));
|
||||
}
|
||||
|
||||
// 检查用户状态
|
||||
if (user.getStatus() == 0) {
|
||||
throw new RuntimeException(I18nUtil.getMessage("error.account.disabled"));
|
||||
}
|
||||
|
||||
// 更新登录信息
|
||||
updateLoginInfo(user.getId(), loginIp);
|
||||
|
||||
// 登录成功,使用 Sa-Token 生成 token(使用 sys 作为登录类型区分)
|
||||
StpUtil.login(user.getId(), "sys");
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLoginInfo(Long userId, String loginIp) {
|
||||
SysUser user = new SysUser();
|
||||
user.setId(userId);
|
||||
user.setLoginIp(loginIp);
|
||||
user.setLoginTime(LocalDateTime.now());
|
||||
this.updateById(user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.TutorialCategoryRelation;
|
||||
import com.corewing.app.mapper.TutorialCategoryRelationMapper;
|
||||
import com.corewing.app.service.TutorialCategoryRelationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TutorialCategoryRelationServiceImpl extends ServiceImpl<TutorialCategoryRelationMapper, TutorialCategoryRelation> implements TutorialCategoryRelationService {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.TutorialCategory;
|
||||
import com.corewing.app.mapper.TutorialCategoryMapper;
|
||||
import com.corewing.app.service.TutorialCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TutorialCategoryServiceImpl extends ServiceImpl<TutorialCategoryMapper, TutorialCategory> implements TutorialCategoryService {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.Tutorial;
|
||||
import com.corewing.app.mapper.TutorialMapper;
|
||||
import com.corewing.app.service.TutorialService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TutorialServiceImpl extends ServiceImpl<TutorialMapper, Tutorial> implements TutorialService {
|
||||
|
||||
private final TutorialMapper tutorialMapper;
|
||||
|
||||
public TutorialServiceImpl(TutorialMapper tutorialMapper) {
|
||||
this.tutorialMapper = tutorialMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang) {
|
||||
return tutorialMapper.pageList(page, categoryId, tutorialTitle, lang);
|
||||
}
|
||||
}
|
||||
58
src/main/java/com/corewing/app/vo/TutorialVO.java
Normal file
58
src/main/java/com/corewing/app/vo/TutorialVO.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.corewing.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class TutorialVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 教程标题
|
||||
*/
|
||||
private String tutorialTitle;
|
||||
|
||||
/**
|
||||
* 教程描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 教程详情
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 查看次数
|
||||
*/
|
||||
private Integer viewCount;
|
||||
|
||||
/**
|
||||
* 推荐状态:0不推荐,1推荐
|
||||
*/
|
||||
private Integer recommendStatus;
|
||||
|
||||
/**
|
||||
* 状态:1正常,2关闭
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 教程分类名称
|
||||
*/
|
||||
private String categoryTitle;
|
||||
|
||||
}
|
||||
44
src/main/resources/db/app_tutorial.sql
Normal file
44
src/main/resources/db/app_tutorial.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : 120.24.204.180
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80036 (8.0.36)
|
||||
Source Host : 120.24.204.180:3306
|
||||
Source Schema : app
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80036 (8.0.36)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/10/2025 13:46:26
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for app_tutorial
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `app_tutorial`;
|
||||
CREATE TABLE `app_tutorial` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`tutorial_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程标题',
|
||||
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程描述',
|
||||
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '教程详情',
|
||||
`view_count` int DEFAULT '0' COMMENT '查看次数',
|
||||
`recommend_status` int DEFAULT '0' COMMENT '推荐状态:0不推荐,1推荐',
|
||||
`status` tinyint(1) DEFAULT '1' COMMENT '状态:1正常,2关闭',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of app_tutorial
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `app_tutorial` (`id`, `tutorial_title`, `description`, `content`, `view_count`, `recommend_status`, `status`, `create_time`, `update_time`) VALUES (1, '快速开始指南', '了解酷翼应用的基本功能与布局,快速上手使用各项功能。', NULL, 0, 0, 1, '2025-10-28 12:03:52', NULL);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
44
src/main/resources/db/app_tutorial_category.sql
Normal file
44
src/main/resources/db/app_tutorial_category.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : 120.24.204.180
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80036 (8.0.36)
|
||||
Source Host : 120.24.204.180:3306
|
||||
Source Schema : app
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80036 (8.0.36)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/10/2025 13:46:32
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for app_tutorial_category
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `app_tutorial_category`;
|
||||
CREATE TABLE `app_tutorial_category` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`icon` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图标',
|
||||
`category_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
|
||||
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类描述',
|
||||
`first_status` int NOT NULL DEFAULT '2' COMMENT '置首页:1置首,2不置首',
|
||||
`type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类别:category分类,tag标签',
|
||||
`status` tinyint(1) DEFAULT '0' COMMENT '状态:1正常,2关闭',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程分类/标签表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of app_tutorial_category
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `app_tutorial_category` (`id`, `icon`, `category_title`, `description`, `first_status`, `type`, `status`, `create_time`, `update_time`) VALUES (1, NULL, '快速指南', NULL, 1, 'category', 1, '2025-10-28 12:06:03', NULL);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
38
src/main/resources/db/app_tutorial_category_relation.sql
Normal file
38
src/main/resources/db/app_tutorial_category_relation.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : 120.24.204.180
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80036 (8.0.36)
|
||||
Source Host : 120.24.204.180:3306
|
||||
Source Schema : app
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80036 (8.0.36)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/10/2025 13:46:38
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for app_tutorial_category_relation
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `app_tutorial_category_relation`;
|
||||
CREATE TABLE `app_tutorial_category_relation` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`tutorial_id` bigint DEFAULT NULL COMMENT '教程id',
|
||||
`category_id` bigint DEFAULT NULL COMMENT '教程分类id',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='教程与教程分类关系表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of app_tutorial_category_relation
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `app_tutorial_category_relation` (`id`, `tutorial_id`, `category_id`) VALUES (1, 1, 1);
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
27
src/main/resources/db/sys_user.sql
Normal file
27
src/main/resources/db/sys_user.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- 后台管理用户表
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
|
||||
CREATE TABLE `sys_user` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
`username` VARCHAR(50) NOT NULL COMMENT '用户名',
|
||||
`password` VARCHAR(100) NOT NULL COMMENT '密码(MD5加密)',
|
||||
`real_name` VARCHAR(50) DEFAULT NULL COMMENT '真实姓名',
|
||||
`email` VARCHAR(100) DEFAULT NULL COMMENT '邮箱',
|
||||
`telephone` VARCHAR(20) DEFAULT NULL COMMENT '手机号',
|
||||
`avatar` VARCHAR(255) DEFAULT NULL COMMENT '头像URL',
|
||||
`login_ip` VARCHAR(50) DEFAULT NULL COMMENT '最后登录IP',
|
||||
`login_time` DATETIME DEFAULT NULL COMMENT '最后登录时间',
|
||||
`status` TINYINT(1) DEFAULT 1 COMMENT '状态:0-禁用 1-启用',
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
`create_time` DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_username` (`username`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='后台管理用户表';
|
||||
|
||||
-- 插入默认管理员账号(密码为:admin123,MD5加密后)
|
||||
INSERT INTO `sys_user` (`username`, `password`, `real_name`, `email`, `status`, `remark`)
|
||||
VALUES
|
||||
('admin', 'e10adc3949ba59abbe56e057f20f883e', '系统管理员', 'admin@corewing.com', 1, '超级管理员账号');
|
||||
@@ -140,3 +140,4 @@ firmware.delete.failed=Failed to delete firmware
|
||||
firmware.update.success=Firmware updated successfully
|
||||
firmware.update.failed=Failed to update firmware
|
||||
firmware.not.found=Firmware not found
|
||||
firmware.type.required=Firmware type is required
|
||||
|
||||
@@ -140,3 +140,4 @@ firmware.delete.failed=固件删除失败
|
||||
firmware.update.success=固件更新成功
|
||||
firmware.update.failed=固件更新失败
|
||||
firmware.not.found=固件不存在
|
||||
firmware.type.required=固件类型不能为空
|
||||
|
||||
44
src/main/resources/mapper/TutorialMapper.xml
Normal file
44
src/main/resources/mapper/TutorialMapper.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.corewing.app.mapper.TutorialMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="VOResultMap" type="com.corewing.app.vo.TutorialVO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="tutorial_title" property="tutorialTitle"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="content" property="content"/>
|
||||
<result column="view_count" property="viewCount"/>
|
||||
<result column="recommend_status" property="recommendStatus"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="category_title" property="categoryTitle"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询SQL片段 -->
|
||||
<sql id="selectVOSql">
|
||||
select c.*, cc.category_title
|
||||
from app_tutorial c
|
||||
left join app_tutorial_category_relation ccr on c.id = ccr.tutorial_id
|
||||
left join app_tutorial_category cc on cc.id = ccr.category_id
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="pageList" resultMap="VOResultMap">
|
||||
<include refid="selectVOSql"/>
|
||||
<where>
|
||||
c.status = 1
|
||||
and c.lang = #{lang}
|
||||
<if test="categoryId != null and categoryId != 0">
|
||||
AND cc.id = #{categoryId}
|
||||
</if>
|
||||
<if test="tutorialTitle != null and tutorialTitle != ''">
|
||||
AND c.tutorial_title like CONCAT('%', #{tutorialTitle}, '%')
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY c.recommend_status,c.create_time asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
494
src/main/resources/static/admin/index.html
Normal file
494
src/main/resources/static/admin/index.html
Normal file
@@ -0,0 +1,494 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>后台管理系统</title>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
--accent-color: #FF6B6B;
|
||||
--error-color: #F43F5E;
|
||||
--success-color: #10B981;
|
||||
--warning-color: #F59E0B;
|
||||
--info-color: #3B82F6;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #F3F4F6;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* 侧边栏样式 */
|
||||
.sidebar {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
color: white;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 180px;
|
||||
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 18px 12px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.sidebar-header h4 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-header i {
|
||||
margin-right: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
padding: 9px 10px;
|
||||
border-radius: 8px;
|
||||
margin: 3px 0;
|
||||
transition: all 0.3s;
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sidebar .nav-link i {
|
||||
width: 18px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover {
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
background-color: rgba(255, 255, 255, 0.25);
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.btn-logout {
|
||||
width: 100%;
|
||||
padding: 9px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.btn-logout:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* 顶部导航栏 */
|
||||
.navbar {
|
||||
background-color: white;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
padding: 12px 25px;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #4B5563;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.user-info i {
|
||||
font-size: 20px;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
/* 主内容区 */
|
||||
.main-content {
|
||||
margin-left: 180px;
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.content-wrapper {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
/* 欢迎卡片 */
|
||||
.welcome-card {
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
color: white;
|
||||
border-radius: 16px;
|
||||
padding: 35px;
|
||||
margin-bottom: 25px;
|
||||
box-shadow: 0 10px 30px rgba(91, 95, 222, 0.2);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.welcome-card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -80px;
|
||||
right: -80px;
|
||||
}
|
||||
|
||||
.welcome-card h2 {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.welcome-card p {
|
||||
font-size: 15px;
|
||||
opacity: 0.95;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* 统计卡片 */
|
||||
.stat-card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s;
|
||||
border: 1px solid #E5E7EB;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.stat-card i {
|
||||
font-size: 40px;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
margin: 12px 0 6px;
|
||||
color: #1F2937;
|
||||
}
|
||||
|
||||
.stat-card p {
|
||||
color: #6B7280;
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.stat-card.primary i { color: var(--primary-color); }
|
||||
.stat-card.success i { color: var(--success-color); }
|
||||
.stat-card.warning i { color: var(--warning-color); }
|
||||
.stat-card.info i { color: var(--info-color); }
|
||||
|
||||
/* 页面标题 */
|
||||
.page-title {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 卡片容器 */
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #E5E7EB;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
position: static;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.welcome-card {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.welcome-card h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- 侧边栏 -->
|
||||
<nav class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h4>
|
||||
<i class="bi bi-shield-lock-fill"></i>
|
||||
CoreWing
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-menu">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'dashboard' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'dashboard'">
|
||||
<i class="bi bi-speedometer2"></i>
|
||||
仪表盘
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'users' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'users'">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
用户管理
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'settings' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'settings'">
|
||||
<i class="bi bi-gear-fill"></i>
|
||||
系统设置
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<button class="btn-logout" @click="handleLogout">
|
||||
<i class="bi bi-box-arrow-right me-2"></i>
|
||||
退出登录
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="main-content">
|
||||
<!-- 顶部导航栏 -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<div class="container-fluid">
|
||||
<span class="navbar-brand">欢迎回来</span>
|
||||
<div class="user-info">
|
||||
<i class="bi bi-person-circle"></i>
|
||||
<span>{{ userInfo.realName || userInfo.username }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="content-wrapper">
|
||||
<!-- 仪表盘 -->
|
||||
<div v-if="currentPage === 'dashboard'">
|
||||
<div class="welcome-card">
|
||||
<h2>
|
||||
<i class="bi bi-emoji-smile"></i>
|
||||
你好,{{ userInfo.realName || userInfo.username }}!
|
||||
</h2>
|
||||
<p class="mb-0 mt-2">欢迎使用 CoreWing 后台管理系统</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card primary">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<h3>1,234</h3>
|
||||
<p>总用户数</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card success">
|
||||
<i class="bi bi-file-earmark-text-fill"></i>
|
||||
<h3>567</h3>
|
||||
<p>文档数量</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card warning">
|
||||
<i class="bi bi-graph-up"></i>
|
||||
<h3>89%</h3>
|
||||
<p>系统负载</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户管理 -->
|
||||
<div v-if="currentPage === 'users'">
|
||||
<h3 class="page-title">用户管理</h3>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>用户管理功能开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 系统设置 -->
|
||||
<div v-if="currentPage === 'settings'">
|
||||
<h3 class="page-title">系统设置</h3>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>系统设置功能开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Vue 3 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
|
||||
|
||||
<!-- Axios -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
userInfo: {
|
||||
username: '',
|
||||
realName: '',
|
||||
userId: ''
|
||||
},
|
||||
currentPage: 'dashboard'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async loadUserInfo() {
|
||||
// 从 localStorage 获取用户信息
|
||||
this.userInfo.username = localStorage.getItem('username') || '';
|
||||
this.userInfo.realName = localStorage.getItem('realName') || '';
|
||||
this.userInfo.userId = localStorage.getItem('userId') || '';
|
||||
|
||||
// 也可以从服务器获取最新的用户信息
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
try {
|
||||
axios.defaults.headers.common['satoken'] = token;
|
||||
const response = await axios.get('/sys/user/info');
|
||||
if (response.data.code === 200) {
|
||||
const user = response.data.data;
|
||||
this.userInfo.username = user.username;
|
||||
this.userInfo.realName = user.realName || user.username;
|
||||
this.userInfo.userId = user.id;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async handleLogout() {
|
||||
if (confirm('确定要退出登录吗?')) {
|
||||
try {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
axios.defaults.headers.common['satoken'] = token;
|
||||
await axios.post('/sys/user/logout');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('退出登录失败:', error);
|
||||
} finally {
|
||||
// 清除本地存储
|
||||
localStorage.clear();
|
||||
// 跳转到登录页
|
||||
window.location.href = '/admin/login.html';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
checkLogin() {
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
// 未登录,跳转到登录页
|
||||
window.location.href = '/admin/login.html';
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 检查登录状态
|
||||
this.checkLogin();
|
||||
// 加载用户信息
|
||||
this.loadUserInfo();
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
497
src/main/resources/static/admin/login.html
Normal file
497
src/main/resources/static/admin/login.html
Normal file
@@ -0,0 +1,497 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>后台管理系统 - 登录</title>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
--accent-color: #FF6B6B;
|
||||
--error-color: #F43F5E;
|
||||
--success-color: #10B981;
|
||||
--warning-color: #F59E0B;
|
||||
--info-color: #3B82F6;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(135deg, #5B5FDE 0%, #0EA5E9 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 背景装饰圆圈 */
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -200px;
|
||||
right: -200px;
|
||||
animation: float 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
body::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 50%;
|
||||
bottom: -100px;
|
||||
left: -100px;
|
||||
animation: float 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%, 100% { transform: translateY(0px) rotate(0deg); }
|
||||
50% { transform: translateY(-20px) rotate(5deg); }
|
||||
}
|
||||
|
||||
.login-container {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
max-width: 1800px;
|
||||
display: flex;
|
||||
background: white;
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 左侧装饰区域 */
|
||||
.login-decoration {
|
||||
flex: 0.9;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
padding: 60px 50px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: white;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-decoration::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -80px;
|
||||
left: -80px;
|
||||
}
|
||||
|
||||
.login-decoration::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 50%;
|
||||
bottom: -60px;
|
||||
right: -60px;
|
||||
}
|
||||
|
||||
.decoration-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.decoration-icon {
|
||||
font-size: 140px;
|
||||
margin-bottom: 40px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
.decoration-content h2 {
|
||||
font-size: 42px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.decoration-content p {
|
||||
font-size: 18px;
|
||||
opacity: 0.95;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 右侧表单区域 */
|
||||
.login-form-section {
|
||||
flex: 1.3;
|
||||
padding: 60px 120px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.form-header h3 {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.form-header p {
|
||||
color: #6B7280;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
position: absolute;
|
||||
left: 18px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--primary-color);
|
||||
font-size: 20px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 16px 18px 16px 52px;
|
||||
border: 2px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
font-size: 16px;
|
||||
transition: all 0.3s;
|
||||
background-color: #F9FAFB;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
background-color: white;
|
||||
box-shadow: 0 0 0 4px rgba(91, 95, 222, 0.1);
|
||||
}
|
||||
|
||||
.form-control::placeholder {
|
||||
color: #9CA3AF;
|
||||
}
|
||||
|
||||
.btn-login {
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
box-shadow: 0 4px 15px rgba(91, 95, 222, 0.3);
|
||||
}
|
||||
|
||||
.btn-login:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px rgba(91, 95, 222, 0.4);
|
||||
}
|
||||
|
||||
.btn-login:active:not(:disabled) {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.btn-login:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 14px 18px;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
animation: slideDown 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background-color: #D1FAE5;
|
||||
color: var(--success-color);
|
||||
border: 1px solid var(--success-color);
|
||||
}
|
||||
|
||||
.alert-danger {
|
||||
background-color: #FEE2E2;
|
||||
color: var(--error-color);
|
||||
border: 1px solid var(--error-color);
|
||||
}
|
||||
|
||||
.alert i {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #E5E7EB;
|
||||
}
|
||||
|
||||
.login-footer small {
|
||||
color: #6B7280;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.spinner-border {
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.login-decoration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
.login-form-section {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="login-container">
|
||||
<!-- 左侧装饰区域 -->
|
||||
<div class="login-decoration">
|
||||
<div class="decoration-content">
|
||||
<div class="decoration-icon">
|
||||
<i class="bi bi-shield-lock-fill"></i>
|
||||
</div>
|
||||
<h2>CoreWing</h2>
|
||||
<p>后台管理系统</p>
|
||||
<p style="margin-top: 20px; opacity: 0.85;">
|
||||
安全 · 高效 · 智能
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧表单区域 -->
|
||||
<div class="login-form-section">
|
||||
<div class="form-header">
|
||||
<h3>欢迎回来</h3>
|
||||
<p>请登录您的账号以继续</p>
|
||||
</div>
|
||||
|
||||
<!-- 提示消息 -->
|
||||
<div v-if="message.text" :class="'alert alert-' + message.type" role="alert">
|
||||
<i :class="'bi bi-' + (message.type === 'success' ? 'check-circle-fill' : 'exclamation-circle-fill')"></i>
|
||||
<span>{{ message.text }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<form @submit.prevent="handleLogin">
|
||||
<div class="form-group">
|
||||
<label class="form-label">用户名</label>
|
||||
<div class="input-wrapper">
|
||||
<i class="bi bi-person-fill input-icon"></i>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入用户名"
|
||||
required
|
||||
autocomplete="username">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">密码</label>
|
||||
<div class="input-wrapper">
|
||||
<i class="bi bi-lock-fill input-icon"></i>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="loginForm.password"
|
||||
placeholder="请输入密码"
|
||||
required
|
||||
autocomplete="current-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn-login"
|
||||
:disabled="loading">
|
||||
<span v-if="loading">
|
||||
<span class="spinner-border spinner-border-sm" role="status" style="margin-right: 8px;"></span>
|
||||
登录中...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-box-arrow-in-right" style="margin-right: 8px;"></i>
|
||||
登录
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="login-footer">
|
||||
<small>默认管理员账号:admin / admin123</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vue 3 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
|
||||
|
||||
<!-- Axios -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
loginForm: {
|
||||
username: '',
|
||||
password: ''
|
||||
},
|
||||
loading: false,
|
||||
message: {
|
||||
text: '',
|
||||
type: 'success' // success, danger
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleLogin() {
|
||||
// 表单验证
|
||||
if (!this.loginForm.username || !this.loginForm.password) {
|
||||
this.showMessage('请填写完整的登录信息', 'danger');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.message.text = '';
|
||||
|
||||
try {
|
||||
const response = await axios.post('/sys/user/login', this.loginForm);
|
||||
|
||||
if (response.data.code === 200) {
|
||||
// 登录成功
|
||||
this.showMessage('登录成功,正在跳转...', 'success');
|
||||
|
||||
// 保存 token 和用户信息
|
||||
localStorage.setItem('token', response.data.data.token);
|
||||
localStorage.setItem('userId', response.data.data.userId);
|
||||
localStorage.setItem('username', response.data.data.username);
|
||||
localStorage.setItem('realName', response.data.data.realName || '');
|
||||
|
||||
// 2秒后跳转到主页
|
||||
setTimeout(() => {
|
||||
window.location.href = '/admin/index.html';
|
||||
}, 2000);
|
||||
} else {
|
||||
// 登录失败
|
||||
this.showMessage(response.data.message || '登录失败', 'danger');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('登录错误:', error);
|
||||
this.showMessage(
|
||||
error.response?.data?.message || '登录失败,请稍后重试',
|
||||
'danger'
|
||||
);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
showMessage(text, type) {
|
||||
this.message.text = text;
|
||||
this.message.type = type;
|
||||
|
||||
// 3秒后自动清除消息(错误消息)
|
||||
if (type === 'danger') {
|
||||
setTimeout(() => {
|
||||
this.message.text = '';
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 检查是否已登录
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
// 如果已有 token,尝试跳转到主页
|
||||
// window.location.href = '/admin/index.html';
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,93 @@
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CoreWing - 后台管理系统</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 72px;
|
||||
margin-bottom: 20px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 48px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 18px;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.3);
|
||||
border-top-color: white;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 自动跳转到后台登录页面
|
||||
window.location.href = '/admin/login.html';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
<div class="container">
|
||||
<div class="logo">🚀</div>
|
||||
<h1>CoreWing</h1>
|
||||
<p>后台管理系统</p>
|
||||
<div class="loading">
|
||||
<div class="spinner"></div>
|
||||
<span>正在跳转...</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user