feat: 开发中...
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
package cn.hamster3.application.blog.config;
|
package cn.hamster3.application.blog.config;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.servlet.FilterChain;
|
import jakarta.servlet.FilterChain;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.cache.Cache;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
@@ -19,30 +17,23 @@ import java.io.IOException;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AuthTokenFilter extends OncePerRequestFilter {
|
public class AuthenticationFilter extends OncePerRequestFilter {
|
||||||
@Resource(name = "userCache")
|
public AuthenticationFilter() {
|
||||||
private Cache userCache;
|
|
||||||
|
|
||||||
public AuthTokenFilter() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull FilterChain filterChain) throws ServletException, IOException {
|
||||||
String token = request.getHeader("token");
|
HttpSession session = request.getSession(false);
|
||||||
log.info("request token: {}", token);
|
if (session == null) {
|
||||||
if (token == null || token.isBlank()) {
|
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserDetails user = userCache.get(token, UserDetails.class);
|
Authentication authentication = (Authentication) session.getAttribute("authenticate");
|
||||||
if (user == null) {
|
if (authentication == null) {
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SecurityContext context = SecurityContextHolder.getContext();
|
SecurityContext context = SecurityContextHolder.getContext();
|
||||||
UsernamePasswordAuthenticationToken authentication = UsernamePasswordAuthenticationToken.authenticated(
|
|
||||||
user, "", user.getAuthorities()
|
|
||||||
);
|
|
||||||
context.setAuthentication(authentication);
|
context.setAuthentication(authentication);
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
}
|
}
|
@@ -1,15 +1,12 @@
|
|||||||
package cn.hamster3.application.blog.config;
|
package cn.hamster3.application.blog.config;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.cache.Cache;
|
|
||||||
import org.springframework.cache.concurrent.ConcurrentMapCache;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.ProviderManager;
|
import org.springframework.security.authentication.ProviderManager;
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.cache.SpringCacheBasedUserCache;
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
@@ -18,11 +15,6 @@ public class WebConfig {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserDetailsService userDetailsService;
|
private UserDetailsService userDetailsService;
|
||||||
|
|
||||||
@Bean(name = "userCache")
|
|
||||||
public Cache getUserCache() {
|
|
||||||
return new ConcurrentMapCache("user-cache");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PasswordEncoder getPasswordEncoder() {
|
public PasswordEncoder getPasswordEncoder() {
|
||||||
return new BCryptPasswordEncoder(5);
|
return new BCryptPasswordEncoder(5);
|
||||||
@@ -33,7 +25,6 @@ public class WebConfig {
|
|||||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||||
provider.setPasswordEncoder(getPasswordEncoder());
|
provider.setPasswordEncoder(getPasswordEncoder());
|
||||||
provider.setUserDetailsService(userDetailsService);
|
provider.setUserDetailsService(userDetailsService);
|
||||||
provider.setUserCache(new SpringCacheBasedUserCache(new ConcurrentMapCache("user-cache")));
|
|
||||||
return new ProviderManager(provider);
|
return new ProviderManager(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ public class DevSecurityConfig {
|
|||||||
.anyRequest().permitAll())
|
.anyRequest().permitAll())
|
||||||
.cors().and()
|
.cors().and()
|
||||||
.csrf().disable()
|
.csrf().disable()
|
||||||
.formLogin().and()
|
|
||||||
.httpBasic().and()
|
.httpBasic().and()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -32,6 +31,7 @@ public class DevSecurityConfig {
|
|||||||
.allowedOriginPatterns("*")
|
.allowedOriginPatterns("*")
|
||||||
.allowedMethods("*")
|
.allowedMethods("*")
|
||||||
.allowedHeaders("*")
|
.allowedHeaders("*")
|
||||||
|
.exposedHeaders("*")
|
||||||
.allowCredentials(true)
|
.allowCredentials(true)
|
||||||
.maxAge(3600);
|
.maxAge(3600);
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,10 @@ import cn.hamster3.application.blog.service.ISettingService;
|
|||||||
import cn.hamster3.application.blog.vo.PageableVO;
|
import cn.hamster3.application.blog.vo.PageableVO;
|
||||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingUpdateRequireVO;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -27,7 +25,7 @@ public class SettingController {
|
|||||||
return settingService.getSettingInfo(id);
|
return settingService.getSettingInfo(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}/content/")
|
@GetMapping(value = "/{id}/content/")
|
||||||
@Operation(summary = "获取网站设置")
|
@Operation(summary = "获取网站设置")
|
||||||
public ResponseVO<String> getSettingContent(@Parameter(description = "设置ID") @PathVariable String id) {
|
public ResponseVO<String> getSettingContent(@Parameter(description = "设置ID") @PathVariable String id) {
|
||||||
return settingService.getSettingContent(id);
|
return settingService.getSettingContent(id);
|
||||||
@@ -42,13 +40,13 @@ public class SettingController {
|
|||||||
return settingService.getSettingInfoList(PageRequest.of(page, Math.max(size, 100)));
|
return settingService.getSettingInfoList(PageRequest.of(page, Math.max(size, 100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}/")
|
@PutMapping(value = "/{id}/", consumes = MediaType.TEXT_PLAIN_VALUE)
|
||||||
@Operation(summary = "更改网站设置")
|
@Operation(summary = "更改网站设置")
|
||||||
public ResponseVO<Void> updateSetting(
|
public ResponseVO<Void> updateSetting(
|
||||||
@Parameter(description = "设置ID") @PathVariable String id,
|
@Parameter(description = "设置ID") @PathVariable String id,
|
||||||
@RequestBody @Valid SettingUpdateRequireVO requireVO
|
@Parameter(description = "设置内容") @RequestBody String content
|
||||||
) {
|
) {
|
||||||
return settingService.updateSetting(id, requireVO);
|
return settingService.updateSetting(id, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}/")
|
@DeleteMapping("/{id}/")
|
||||||
|
@@ -13,7 +13,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -30,8 +30,8 @@ public class UserController {
|
|||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@Operation(summary = "登录用户")
|
@Operation(summary = "登录用户")
|
||||||
public ResponseVO<Void> loginUser(@RequestBody @Valid UserLoginRequireVO requireVO, HttpServletResponse response) {
|
public ResponseVO<Void> loginUser(HttpServletRequest request, @RequestBody @Valid UserLoginRequireVO requireVO) {
|
||||||
return userService.loginUser(requireVO, response);
|
return userService.loginUser(request, requireVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/current")
|
@GetMapping("/current")
|
||||||
|
@@ -3,7 +3,6 @@ package cn.hamster3.application.blog.service;
|
|||||||
import cn.hamster3.application.blog.vo.PageableVO;
|
import cn.hamster3.application.blog.vo.PageableVO;
|
||||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingUpdateRequireVO;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ public interface ISettingService {
|
|||||||
|
|
||||||
@NotNull ResponseVO<PageableVO<SettingInfoResponseVO>> getSettingInfoList(@NotNull Pageable pageable);
|
@NotNull ResponseVO<PageableVO<SettingInfoResponseVO>> getSettingInfoList(@NotNull Pageable pageable);
|
||||||
|
|
||||||
@NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull SettingUpdateRequireVO requireVO);
|
@NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull String content);
|
||||||
|
|
||||||
@NotNull ResponseVO<Void> deleteSetting(@NotNull String id);
|
@NotNull ResponseVO<Void> deleteSetting(@NotNull String id);
|
||||||
}
|
}
|
||||||
|
@@ -8,14 +8,14 @@ import cn.hamster3.application.blog.vo.user.UserCreateRequireVO;
|
|||||||
import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.user.UserLoginRequireVO;
|
import cn.hamster3.application.blog.vo.user.UserLoginRequireVO;
|
||||||
import cn.hamster3.application.blog.vo.user.UserUpdateRequireVO;
|
import cn.hamster3.application.blog.vo.user.UserUpdateRequireVO;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface IUserService {
|
public interface IUserService {
|
||||||
@NotNull ResponseVO<Void> loginUser(@NotNull UserLoginRequireVO requireVO, @NotNull HttpServletResponse response);
|
@NotNull ResponseVO<Void> loginUser(@NotNull HttpServletRequest request, @NotNull UserLoginRequireVO requireVO);
|
||||||
|
|
||||||
@NotNull ResponseVO<UserInfoResponseVO> getCurrentUserInfo();
|
@NotNull ResponseVO<UserInfoResponseVO> getCurrentUserInfo();
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@ import cn.hamster3.application.blog.util.BlogUtils;
|
|||||||
import cn.hamster3.application.blog.vo.PageableVO;
|
import cn.hamster3.application.blog.vo.PageableVO;
|
||||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
import cn.hamster3.application.blog.vo.setting.SettingInfoResponseVO;
|
||||||
import cn.hamster3.application.blog.vo.setting.SettingUpdateRequireVO;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -50,7 +49,7 @@ public class SettingService implements ISettingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull SettingUpdateRequireVO requireVO) {
|
public @NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull String content) {
|
||||||
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
||||||
if (check != null) {
|
if (check != null) {
|
||||||
return check;
|
return check;
|
||||||
@@ -58,10 +57,10 @@ public class SettingService implements ISettingService {
|
|||||||
if (!settingRepo.existsByIdIgnoreCase(id)) {
|
if (!settingRepo.existsByIdIgnoreCase(id)) {
|
||||||
SettingEntity entity = new SettingEntity();
|
SettingEntity entity = new SettingEntity();
|
||||||
entity.setId(id);
|
entity.setId(id);
|
||||||
entity.setContent(requireVO.getContent());
|
entity.setContent(content);
|
||||||
settingRepo.save(entity);
|
settingRepo.save(entity);
|
||||||
} else {
|
} else {
|
||||||
settingRepo.updateContentByIdIgnoreCase(requireVO.getContent(), id);
|
settingRepo.updateContentByIdIgnoreCase(content, id);
|
||||||
}
|
}
|
||||||
return ResponseVO.success();
|
return ResponseVO.success();
|
||||||
}
|
}
|
||||||
|
@@ -20,10 +20,10 @@ import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
|||||||
import cn.hamster3.application.blog.vo.user.UserLoginRequireVO;
|
import cn.hamster3.application.blog.vo.user.UserLoginRequireVO;
|
||||||
import cn.hamster3.application.blog.vo.user.UserUpdateRequireVO;
|
import cn.hamster3.application.blog.vo.user.UserUpdateRequireVO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.cache.Cache;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
@@ -52,14 +52,11 @@ public class UserService implements IUserService {
|
|||||||
private BlogRepository blogRepo;
|
private BlogRepository blogRepo;
|
||||||
@Resource
|
@Resource
|
||||||
private AttachRepository attachRepo;
|
private AttachRepository attachRepo;
|
||||||
|
|
||||||
@Resource(name = "userCache")
|
|
||||||
private Cache userCache;
|
|
||||||
@Resource
|
@Resource
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ResponseVO<Void> loginUser(@NotNull UserLoginRequireVO requireVO, @NotNull HttpServletResponse response) {
|
public @NotNull ResponseVO<Void> loginUser(@NotNull HttpServletRequest request, @NotNull UserLoginRequireVO requireVO) {
|
||||||
Authentication authenticate = authenticationManager.authenticate(
|
Authentication authenticate = authenticationManager.authenticate(
|
||||||
new UsernamePasswordAuthenticationToken(requireVO.getEmail(), requireVO.getPassword())
|
new UsernamePasswordAuthenticationToken(requireVO.getEmail(), requireVO.getPassword())
|
||||||
);
|
);
|
||||||
@@ -67,9 +64,8 @@ public class UserService implements IUserService {
|
|||||||
if (!authenticate.isAuthenticated()) {
|
if (!authenticate.isAuthenticated()) {
|
||||||
return ResponseVO.failed("login failed.");
|
return ResponseVO.failed("login failed.");
|
||||||
}
|
}
|
||||||
UUID uuid = UUID.randomUUID();
|
HttpSession session = request.getSession();
|
||||||
userCache.put(uuid.toString(), authenticate.getPrincipal());
|
session.setAttribute("authenticate", authenticate);
|
||||||
response.addHeader("token", uuid.toString());
|
|
||||||
return ResponseVO.success();
|
return ResponseVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ public class BlogUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static Optional<BlogUser> getCurrentUser() {
|
public static Optional<BlogUser> getCurrentUser() {
|
||||||
Authentication authentication = getCurrentAuthentication();
|
Authentication authentication = getCurrentAuthentication();
|
||||||
log.info("==============================");
|
|
||||||
if (authentication == null) {
|
if (authentication == null) {
|
||||||
log.info("current user authentication: null");
|
log.info("current user authentication: null");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@@ -1,32 +1,37 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { RouterLink, RouterView } from 'vue-router'
|
import { RouterLink, RouterView } from 'vue-router'
|
||||||
import { SettingControllerApiFactory, UserControllerApiFactory, UserInfoResponseVORoleEnum, type UserInfoResponseVO } from '@/api-base';
|
import { UserInfoResponseVORoleEnum } from "@/swagger";
|
||||||
|
import { api, globalStore, siteSetting } from "@/api"
|
||||||
|
import { updateCurrentUserInfo } from '@/utils';
|
||||||
|
|
||||||
let title = ref<string>("网站标题")
|
let currentUserInfo = globalStore.currentUserInfo
|
||||||
let navigationMenu = ref([{
|
let navigationMenu = siteSetting.customNavigationMenu
|
||||||
url: "/about",
|
|
||||||
text: "关于我"
|
|
||||||
}])
|
|
||||||
let currentUserInfo = ref<UserInfoResponseVO | null>(null)
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
SettingControllerApiFactory().getSettingContent("site.title")
|
// 获取站点标题
|
||||||
.then(response => {
|
api.SettingController.getSettingContent("site.title")
|
||||||
let vo = response.data;
|
|
||||||
let siteTitle: string = vo.data ?? "网站标题"
|
|
||||||
title.value = siteTitle
|
|
||||||
document.title = siteTitle
|
|
||||||
})
|
|
||||||
|
|
||||||
SettingControllerApiFactory().getSettingContent("site.navigation.menus")
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let vo = response.data;
|
let vo = response.data;
|
||||||
if (vo.code === 200) {
|
if (vo.code === 200) {
|
||||||
let navigationMenuObject = JSON.parse(vo.data || "{}")
|
let title = vo.data ?? "网站标题"
|
||||||
|
siteSetting.title.value = title
|
||||||
|
document.title = title
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取站点自定义导航栏
|
||||||
|
api.SettingController.getSettingContent("site.navigation.menus")
|
||||||
|
.then(response => {
|
||||||
|
let vo = response.data;
|
||||||
|
if (vo.code === 200) {
|
||||||
|
let navigationMenuObject = JSON.parse(vo.data || "[]")
|
||||||
navigationMenu.value = navigationMenuObject
|
navigationMenu.value = navigationMenuObject
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 获取当前登录的用户信息
|
||||||
|
updateCurrentUserInfo();
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -36,7 +41,7 @@ onMounted(() => {
|
|||||||
<el-header>
|
<el-header>
|
||||||
<el-menu default-active="index" mode="horizontal" :ellipsis="false">
|
<el-menu default-active="index" mode="horizontal" :ellipsis="false">
|
||||||
<el-menu-item index="index">
|
<el-menu-item index="index">
|
||||||
<router-link to="/">{{ title }}</router-link>
|
<router-link to="/">{{ siteSetting.title.value }}</router-link>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="tags">
|
<el-menu-item index="tags">
|
||||||
<router-link to="/tags">标签</router-link>
|
<router-link to="/tags">标签</router-link>
|
||||||
@@ -47,14 +52,14 @@ onMounted(() => {
|
|||||||
|
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
|
|
||||||
<el-menu-item index="login" v-if="!currentUserInfo">
|
<el-menu-item index="login" v-if="!currentUserInfo.id">
|
||||||
<router-link to="/login">登录</router-link>
|
<router-link to="/login">登录</router-link>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="register" v-if="!currentUserInfo">
|
<el-menu-item index="register" v-if="!currentUserInfo.id">
|
||||||
<router-link to="/register">注册</router-link>
|
<router-link to="/register">注册</router-link>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="register" v-if="currentUserInfo?.role === UserInfoResponseVORoleEnum.ADMIN">
|
<el-menu-item index="settings" v-if="currentUserInfo?.role === UserInfoResponseVORoleEnum.ADMIN">
|
||||||
<router-link to="/register">设置</router-link>
|
<router-link to="/settings">设置</router-link>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-header>
|
</el-header>
|
||||||
@@ -63,6 +68,10 @@ onMounted(() => {
|
|||||||
</el-main>
|
</el-main>
|
||||||
<el-footer>
|
<el-footer>
|
||||||
<p>
|
<p>
|
||||||
|
<a href="https://cn.vuejs.org/">Vue3</a>
|
||||||
|
|
|
||||||
|
<a href="https://element-plus.gitee.io/zh-CN/">Element UI Plus</a>
|
||||||
|
|
|
||||||
<a href="/swagger-ui/index.html">Swagger</a>
|
<a href="/swagger-ui/index.html">Swagger</a>
|
||||||
|
|
|
|
||||||
<a href="https://editor.swagger.io/">Editor</a>
|
<a href="https://editor.swagger.io/">Editor</a>
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* OpenAPI definition
|
|
||||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: v0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface SettingUpdateRequireVO
|
|
||||||
*/
|
|
||||||
export interface SettingUpdateRequireVO {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof SettingUpdateRequireVO
|
|
||||||
*/
|
|
||||||
content: string;
|
|
||||||
}
|
|
8
blog-frontend/src/api/api.ts
Normal file
8
blog-frontend/src/api/api.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { UserControllerApiFactory, BlogControllerApiFactory, SettingControllerApiFactory, AttachControllerApiFactory } from "@/swagger"
|
||||||
|
|
||||||
|
export const api = {
|
||||||
|
AttachController: AttachControllerApiFactory(),
|
||||||
|
UserController: UserControllerApiFactory(),
|
||||||
|
BlogController: BlogControllerApiFactory(),
|
||||||
|
SettingController: SettingControllerApiFactory()
|
||||||
|
}
|
12
blog-frontend/src/api/global-store.ts
Normal file
12
blog-frontend/src/api/global-store.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { reactive, ref } from "vue"
|
||||||
|
import type { NavigationMenu } from "@/api"
|
||||||
|
import type { UserInfoResponseVO } from "@/swagger"
|
||||||
|
|
||||||
|
export const globalStore = {
|
||||||
|
currentUserInfo: ref<UserInfoResponseVO>({})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const siteSetting = {
|
||||||
|
title: ref<string>("网站标题"),
|
||||||
|
customNavigationMenu: ref<Array<NavigationMenu>>([])
|
||||||
|
}
|
4
blog-frontend/src/api/index.ts
Normal file
4
blog-frontend/src/api/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./api"
|
||||||
|
export * from "./global-store"
|
||||||
|
export * from "./types"
|
||||||
|
export * from "@/swagger"
|
1
blog-frontend/src/api/types/index.ts
Normal file
1
blog-frontend/src/api/types/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./navigation-menu"
|
6
blog-frontend/src/api/types/navigation-menu.ts
Normal file
6
blog-frontend/src/api/types/navigation-menu.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
interface NavigationMenu {
|
||||||
|
url: string,
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { NavigationMenu }
|
4
blog-frontend/src/swagger/.gitignore
vendored
Normal file
4
blog-frontend/src/swagger/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
wwwroot/*.js
|
||||||
|
node_modules
|
||||||
|
typings
|
||||||
|
dist
|
1
blog-frontend/src/swagger/.npmignore
Normal file
1
blog-frontend/src/swagger/.npmignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
23
blog-frontend/src/swagger/.swagger-codegen-ignore
Normal file
23
blog-frontend/src/swagger/.swagger-codegen-ignore
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Swagger Codegen Ignore
|
||||||
|
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
1
blog-frontend/src/swagger/.swagger-codegen/VERSION
Normal file
1
blog-frontend/src/swagger/.swagger-codegen/VERSION
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0.41
|
45
blog-frontend/src/swagger/README.md
Normal file
45
blog-frontend/src/swagger/README.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
## @
|
||||||
|
|
||||||
|
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||||
|
|
||||||
|
Environment
|
||||||
|
* Node.js
|
||||||
|
* Webpack
|
||||||
|
* Browserify
|
||||||
|
|
||||||
|
Language level
|
||||||
|
* ES5 - you must have a Promises/A+ library installed
|
||||||
|
* ES6
|
||||||
|
|
||||||
|
Module system
|
||||||
|
* CommonJS
|
||||||
|
* ES6 module system
|
||||||
|
|
||||||
|
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
To build and compile the typescript sources to javascript use:
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Publishing
|
||||||
|
|
||||||
|
First build the package then run ```npm publish```
|
||||||
|
|
||||||
|
### Consuming
|
||||||
|
|
||||||
|
navigate to the folder of your consuming project and run one of the following commands.
|
||||||
|
|
||||||
|
_published:_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install @ --save
|
||||||
|
```
|
||||||
|
|
||||||
|
_unPublished (not recommended):_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install PATH_TO_GENERATED_PACKAGE --save
|
@@ -20,7 +20,6 @@ import { ResponseVOPageableVOSettingInfoResponseVO } from '../models';
|
|||||||
import { ResponseVOSettingInfoResponseVO } from '../models';
|
import { ResponseVOSettingInfoResponseVO } from '../models';
|
||||||
import { ResponseVOString } from '../models';
|
import { ResponseVOString } from '../models';
|
||||||
import { ResponseVOVoid } from '../models';
|
import { ResponseVOVoid } from '../models';
|
||||||
import { SettingUpdateRequireVO } from '../models';
|
|
||||||
/**
|
/**
|
||||||
* SettingControllerApi - axios parameter creator
|
* SettingControllerApi - axios parameter creator
|
||||||
* @export
|
* @export
|
||||||
@@ -202,12 +201,12 @@ export const SettingControllerApiAxiosParamCreator = function (configuration?: C
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {SettingUpdateRequireVO} body
|
* @param {string} body
|
||||||
* @param {string} id 设置ID
|
* @param {string} id 设置ID
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
updateSetting: async (body: SettingUpdateRequireVO, id: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
updateSetting: async (body: string, id: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
// verify required parameter 'body' is not null or undefined
|
// verify required parameter 'body' is not null or undefined
|
||||||
if (body === null || body === undefined) {
|
if (body === null || body === undefined) {
|
||||||
throw new RequiredError('body','Required parameter body was null or undefined when calling updateSetting.');
|
throw new RequiredError('body','Required parameter body was null or undefined when calling updateSetting.');
|
||||||
@@ -228,7 +227,7 @@ export const SettingControllerApiAxiosParamCreator = function (configuration?: C
|
|||||||
const localVarHeaderParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const localVarQueryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
localVarHeaderParameter['Content-Type'] = 'text/plain';
|
||||||
|
|
||||||
const query = new URLSearchParams(localVarUrlObj.search);
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
for (const key in localVarQueryParameter) {
|
for (const key in localVarQueryParameter) {
|
||||||
@@ -317,12 +316,12 @@ export const SettingControllerApiFp = function(configuration?: Configuration) {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {SettingUpdateRequireVO} body
|
* @param {string} body
|
||||||
* @param {string} id 设置ID
|
* @param {string} id 设置ID
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async updateSetting(body: SettingUpdateRequireVO, id: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOVoid>>> {
|
async updateSetting(body: string, id: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOVoid>>> {
|
||||||
const localVarAxiosArgs = await SettingControllerApiAxiosParamCreator(configuration).updateSetting(body, id, options);
|
const localVarAxiosArgs = await SettingControllerApiAxiosParamCreator(configuration).updateSetting(body, id, options);
|
||||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
@@ -382,12 +381,12 @@ export const SettingControllerApiFactory = function (configuration?: Configurati
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {SettingUpdateRequireVO} body
|
* @param {string} body
|
||||||
* @param {string} id 设置ID
|
* @param {string} id 设置ID
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
async updateSetting(body: SettingUpdateRequireVO, id: string, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
async updateSetting(body: string, id: string, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
return SettingControllerApiFp(configuration).updateSetting(body, id, options).then((request) => request(axios, basePath));
|
return SettingControllerApiFp(configuration).updateSetting(body, id, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -448,13 +447,13 @@ export class SettingControllerApi extends BaseAPI {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {SettingUpdateRequireVO} body
|
* @param {string} body
|
||||||
* @param {string} id 设置ID
|
* @param {string} id 设置ID
|
||||||
* @param {*} [options] Override http request option.
|
* @param {*} [options] Override http request option.
|
||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
* @memberof SettingControllerApi
|
* @memberof SettingControllerApi
|
||||||
*/
|
*/
|
||||||
public async updateSetting(body: SettingUpdateRequireVO, id: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
public async updateSetting(body: string, id: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
return SettingControllerApiFp(this.configuration).updateSetting(body, id, options).then((request) => request(this.axios, this.basePath));
|
return SettingControllerApiFp(this.configuration).updateSetting(body, id, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -30,49 +30,6 @@ import { UserUpdateRequireVO } from '../models';
|
|||||||
*/
|
*/
|
||||||
export const UserControllerApiAxiosParamCreator = function (configuration?: Configuration) {
|
export const UserControllerApiAxiosParamCreator = function (configuration?: Configuration) {
|
||||||
return {
|
return {
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 注册用户
|
|
||||||
* @param {UserCreateRequireVO} body
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
createUser: async (body: UserCreateRequireVO, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
||||||
// verify required parameter 'body' is not null or undefined
|
|
||||||
if (body === null || body === undefined) {
|
|
||||||
throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.');
|
|
||||||
}
|
|
||||||
const localVarPath = `/api/v1/user/`;
|
|
||||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
||||||
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
|
||||||
let baseOptions;
|
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
|
||||||
const localVarHeaderParameter = {} as any;
|
|
||||||
const localVarQueryParameter = {} as any;
|
|
||||||
|
|
||||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
||||||
|
|
||||||
const query = new URLSearchParams(localVarUrlObj.search);
|
|
||||||
for (const key in localVarQueryParameter) {
|
|
||||||
query.set(key, localVarQueryParameter[key]);
|
|
||||||
}
|
|
||||||
for (const key in options.params) {
|
|
||||||
query.set(key, options.params[key]);
|
|
||||||
}
|
|
||||||
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
||||||
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
|
||||||
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
|
||||||
options: localVarRequestOptions,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 查询用户列表
|
* @summary 查询用户列表
|
||||||
@@ -358,6 +315,49 @@ export const UserControllerApiAxiosParamCreator = function (configuration?: Conf
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 注册用户
|
||||||
|
* @param {UserCreateRequireVO} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
register: async (body: UserCreateRequireVO, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
// verify required parameter 'body' is not null or undefined
|
||||||
|
if (body === null || body === undefined) {
|
||||||
|
throw new RequiredError('body','Required parameter body was null or undefined when calling register.');
|
||||||
|
}
|
||||||
|
const localVarPath = `/api/v1/user/`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||||
|
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更新用户信息
|
* @summary 更新用户信息
|
||||||
@@ -416,20 +416,6 @@ export const UserControllerApiAxiosParamCreator = function (configuration?: Conf
|
|||||||
*/
|
*/
|
||||||
export const UserControllerApiFp = function(configuration?: Configuration) {
|
export const UserControllerApiFp = function(configuration?: Configuration) {
|
||||||
return {
|
return {
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 注册用户
|
|
||||||
* @param {UserCreateRequireVO} body
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async createUser(body: UserCreateRequireVO, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOUserInfoResponseVO>>> {
|
|
||||||
const localVarAxiosArgs = await UserControllerApiAxiosParamCreator(configuration).createUser(body, options);
|
|
||||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
||||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
|
||||||
return axios.request(axiosRequestArgs);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 查询用户列表
|
* @summary 查询用户列表
|
||||||
@@ -518,6 +504,20 @@ export const UserControllerApiFp = function(configuration?: Configuration) {
|
|||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 注册用户
|
||||||
|
* @param {UserCreateRequireVO} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async register(body: UserCreateRequireVO, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOUserInfoResponseVO>>> {
|
||||||
|
const localVarAxiosArgs = await UserControllerApiAxiosParamCreator(configuration).register(body, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更新用户信息
|
* @summary 更新用户信息
|
||||||
@@ -542,16 +542,6 @@ export const UserControllerApiFp = function(configuration?: Configuration) {
|
|||||||
*/
|
*/
|
||||||
export const UserControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
export const UserControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
||||||
return {
|
return {
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 注册用户
|
|
||||||
* @param {UserCreateRequireVO} body
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async createUser(body: UserCreateRequireVO, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOUserInfoResponseVO>> {
|
|
||||||
return UserControllerApiFp(configuration).createUser(body, options).then((request) => request(axios, basePath));
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 查询用户列表
|
* @summary 查询用户列表
|
||||||
@@ -616,6 +606,16 @@ export const UserControllerApiFactory = function (configuration?: Configuration,
|
|||||||
async loginUser(body: UserLoginRequireVO, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
async loginUser(body: UserLoginRequireVO, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
return UserControllerApiFp(configuration).loginUser(body, options).then((request) => request(axios, basePath));
|
return UserControllerApiFp(configuration).loginUser(body, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 注册用户
|
||||||
|
* @param {UserCreateRequireVO} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async register(body: UserCreateRequireVO, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOUserInfoResponseVO>> {
|
||||||
|
return UserControllerApiFp(configuration).register(body, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更新用户信息
|
* @summary 更新用户信息
|
||||||
@@ -637,17 +637,6 @@ export const UserControllerApiFactory = function (configuration?: Configuration,
|
|||||||
* @extends {BaseAPI}
|
* @extends {BaseAPI}
|
||||||
*/
|
*/
|
||||||
export class UserControllerApi extends BaseAPI {
|
export class UserControllerApi extends BaseAPI {
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 注册用户
|
|
||||||
* @param {UserCreateRequireVO} body
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
* @memberof UserControllerApi
|
|
||||||
*/
|
|
||||||
public async createUser(body: UserCreateRequireVO, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOUserInfoResponseVO>> {
|
|
||||||
return UserControllerApiFp(this.configuration).createUser(body, options).then((request) => request(this.axios, this.basePath));
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 查询用户列表
|
* @summary 查询用户列表
|
||||||
@@ -718,6 +707,17 @@ export class UserControllerApi extends BaseAPI {
|
|||||||
public async loginUser(body: UserLoginRequireVO, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
public async loginUser(body: UserLoginRequireVO, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
return UserControllerApiFp(this.configuration).loginUser(body, options).then((request) => request(this.axios, this.basePath));
|
return UserControllerApiFp(this.configuration).loginUser(body, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 注册用户
|
||||||
|
* @param {UserCreateRequireVO} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof UserControllerApi
|
||||||
|
*/
|
||||||
|
public async register(body: UserCreateRequireVO, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOUserInfoResponseVO>> {
|
||||||
|
return UserControllerApiFp(this.configuration).register(body, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更新用户信息
|
* @summary 更新用户信息
|
52
blog-frontend/src/swagger/git_push.sh
Normal file
52
blog-frontend/src/swagger/git_push.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh hugomario swagger-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=`git remote`
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
@@ -21,7 +21,6 @@ export * from './response-vostring';
|
|||||||
export * from './response-vouser-info-response-vo';
|
export * from './response-vouser-info-response-vo';
|
||||||
export * from './response-vovoid';
|
export * from './response-vovoid';
|
||||||
export * from './setting-info-response-vo';
|
export * from './setting-info-response-vo';
|
||||||
export * from './setting-update-require-vo';
|
|
||||||
export * from './user-create-require-vo';
|
export * from './user-create-require-vo';
|
||||||
export * from './user-entity';
|
export * from './user-entity';
|
||||||
export * from './user-info-response-vo';
|
export * from './user-info-response-vo';
|
15
blog-frontend/src/utils/index.ts
Normal file
15
blog-frontend/src/utils/index.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { api, globalStore } from "@/api";
|
||||||
|
|
||||||
|
|
||||||
|
export function updateCurrentUserInfo() {
|
||||||
|
api.UserController.getCurrentUserInfo({ withCredentials: true })
|
||||||
|
.then(resp => {
|
||||||
|
let vo = resp.data
|
||||||
|
if (vo.code === 200) {
|
||||||
|
globalStore.currentUserInfo.value = vo.data || {}
|
||||||
|
console.log("current user info: ", vo.data)
|
||||||
|
} else {
|
||||||
|
console.error("ckeck current user info failed!")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { UserControllerApiFactory } from '@/api-base';
|
|
||||||
import type UserLoginRequireVO from '@/api-base';
|
|
||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
|
import { api } from '@/api';
|
||||||
|
import { updateCurrentUserInfo } from '@/utils';
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
email: '',
|
email: '',
|
||||||
@@ -9,14 +9,16 @@ const form = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
UserControllerApiFactory().loginUser(form)
|
api.UserController.loginUser(form, { withCredentials: true })
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
let vo = resp.data;
|
let vo = resp.data;
|
||||||
if (vo.data === 200) {
|
if (vo.code === 200) {
|
||||||
console.log('login success!')
|
console.log('login success!')
|
||||||
} else {
|
} else {
|
||||||
|
console.log(vo.msg)
|
||||||
console.log('login failed!')
|
console.log('login failed!')
|
||||||
}
|
}
|
||||||
|
updateCurrentUserInfo();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,13 +1,22 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { api, siteSetting } from '@/api';
|
||||||
|
|
||||||
|
const changeTitle = () => {
|
||||||
|
api.SettingController.updateSetting(siteSetting.title.value, "site.title", { withCredentials: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSettings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
abc
|
||||||
|
<el-input v-model="siteSetting.title.value" placeholder="Please input" @change="changeTitle" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
</script>
|
<style scoped></style>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
Reference in New Issue
Block a user