feat: 开发中...
This commit is contained in:
@@ -4,6 +4,7 @@ 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;
|
||||||
@@ -12,6 +13,8 @@ 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.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "SettingController", description = "网站设置相关接口")
|
@Tag(name = "SettingController", description = "网站设置相关接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/api/v1/settings", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/api/v1/settings", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@@ -40,13 +43,19 @@ public class SettingController {
|
|||||||
return settingService.getSettingInfoList(PageRequest.of(page, Math.min(size, 100)));
|
return settingService.getSettingInfoList(PageRequest.of(page, Math.min(size, 100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping(value = "/{id}/", consumes = MediaType.TEXT_PLAIN_VALUE)
|
@PutMapping(value = "/{id}/")
|
||||||
@Operation(summary = "更改网站设置")
|
@Operation(summary = "更改网站设置")
|
||||||
public ResponseVO<Void> updateSetting(
|
public ResponseVO<Void> updateSetting(
|
||||||
@Parameter(description = "设置ID") @PathVariable String id,
|
@Parameter(description = "设置ID") @PathVariable String id,
|
||||||
@Parameter(description = "设置内容") @RequestBody String content
|
@Parameter(description = "设置内容") @RequestBody SettingUpdateRequireVO requireVO
|
||||||
) {
|
) {
|
||||||
return settingService.updateSetting(id, content);
|
return settingService.updateSetting(id, requireVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping(value = "/")
|
||||||
|
@Operation(summary = "批量更改网站设置")
|
||||||
|
public ResponseVO<Void> updateSettings(@Parameter(description = "设置内容") @RequestBody Map<String, String> data) {
|
||||||
|
return settingService.updateSettings(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}/")
|
@DeleteMapping("/{id}/")
|
||||||
|
@@ -3,9 +3,12 @@ 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;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ISettingService {
|
public interface ISettingService {
|
||||||
@NotNull ResponseVO<SettingInfoResponseVO> getSettingInfo(@NotNull String id);
|
@NotNull ResponseVO<SettingInfoResponseVO> getSettingInfo(@NotNull String id);
|
||||||
|
|
||||||
@@ -13,7 +16,9 @@ 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 String content);
|
@NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull SettingUpdateRequireVO requireVO);
|
||||||
|
|
||||||
|
@NotNull ResponseVO<Void> updateSettings(@NotNull Map<String, String> data);
|
||||||
|
|
||||||
@NotNull ResponseVO<Void> deleteSetting(@NotNull String id);
|
@NotNull ResponseVO<Void> deleteSetting(@NotNull String id);
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,15 @@ 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;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SettingService implements ISettingService {
|
public class SettingService implements ISettingService {
|
||||||
@@ -49,7 +52,8 @@ public class SettingService implements ISettingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull String content) {
|
public @NotNull ResponseVO<Void> updateSetting(@NotNull String id, @NotNull SettingUpdateRequireVO requireVO) {
|
||||||
|
String content = requireVO.getContent();
|
||||||
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
||||||
if (check != null) {
|
if (check != null) {
|
||||||
return check;
|
return check;
|
||||||
@@ -65,6 +69,27 @@ public class SettingService implements ISettingService {
|
|||||||
return ResponseVO.success();
|
return ResponseVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ResponseVO<Void> updateSettings(@NotNull Map<String, String> data) {
|
||||||
|
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
||||||
|
if (check != null) {
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, String> entry : data.entrySet()) {
|
||||||
|
String id = entry.getKey();
|
||||||
|
String content = entry.getValue();
|
||||||
|
if (!settingRepo.existsByIdIgnoreCase(id)) {
|
||||||
|
SettingEntity entity = new SettingEntity();
|
||||||
|
entity.setId(id);
|
||||||
|
entity.setContent(content);
|
||||||
|
settingRepo.save(entity);
|
||||||
|
} else {
|
||||||
|
settingRepo.updateContentByIdIgnoreCase(content, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseVO.success();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ResponseVO<Void> deleteSetting(@NotNull String id) {
|
public @NotNull ResponseVO<Void> deleteSetting(@NotNull String id) {
|
||||||
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
ResponseVO<Void> check = BlogUtils.checkAdminPermission();
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package cn.hamster3.application.blog.vo.setting;
|
package cn.hamster3.application.blog.vo.setting;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -9,6 +8,5 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SettingUpdateRequireVO {
|
public class SettingUpdateRequireVO {
|
||||||
@NotBlank(message = "网站设置内容不能为空!")
|
|
||||||
private String content;
|
private String content;
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="叁只仓鼠的个人博客">
|
<meta name="description" content="叁只仓鼠的个人博客">
|
||||||
<title>网站标题</title>
|
<title>网站标题</title>
|
||||||
|
<style id="custom-css">
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@@ -1,22 +1,36 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onMounted } from 'vue';
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import HeaderComponent from "@/components/HeaderComponent.vue"
|
import HeaderComponent from "@/components/HeaderComponent.vue"
|
||||||
import FooterComponent from "@/components/FooterComponent.vue"
|
import FooterComponent from "@/components/FooterComponent.vue"
|
||||||
|
|
||||||
import { load } from './api';
|
import { api, loadGlobalStore, siteSetting } from '@/api';
|
||||||
|
|
||||||
load();
|
loadGlobalStore();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
api.SettingController.getSettingContent(siteSetting.keys.site.css)
|
||||||
|
.then(resp => {
|
||||||
|
const vo = resp.data
|
||||||
|
if (vo.code === 200) {
|
||||||
|
const cssText = vo.data ?? ""
|
||||||
|
let cssElement = document.getElementById("custom-css")
|
||||||
|
siteSetting.css = cssText
|
||||||
|
if (cssElement != null) cssElement.innerText = cssText
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-container class="blog-container">
|
<el-container class="blog-container">
|
||||||
<el-header>
|
<el-header class="blog-header">
|
||||||
<HeaderComponent />
|
<HeaderComponent />
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main>
|
<el-main class="blog-main">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</el-main>
|
</el-main>
|
||||||
<el-footer>
|
<el-footer class="blog-footer">
|
||||||
<FooterComponent />
|
<FooterComponent />
|
||||||
</el-footer>
|
</el-footer>
|
||||||
</el-container>
|
</el-container>
|
||||||
|
@@ -1,8 +1,14 @@
|
|||||||
import { UserControllerApiFactory, BlogControllerApiFactory, SettingControllerApiFactory, AttachControllerApiFactory } from "@/swagger"
|
import { UserControllerApiFactory, BlogControllerApiFactory, SettingControllerApiFactory, AttachControllerApiFactory, Configuration } from "@/swagger"
|
||||||
|
|
||||||
|
export const apiConfig: Configuration = {
|
||||||
|
baseOptions: {
|
||||||
|
withCredentials: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const api = {
|
export const api = {
|
||||||
AttachController: AttachControllerApiFactory(),
|
AttachController: AttachControllerApiFactory(apiConfig),
|
||||||
UserController: UserControllerApiFactory(),
|
UserController: UserControllerApiFactory(apiConfig),
|
||||||
BlogController: BlogControllerApiFactory(),
|
BlogController: BlogControllerApiFactory(apiConfig),
|
||||||
SettingController: SettingControllerApiFactory()
|
SettingController: SettingControllerApiFactory(apiConfig)
|
||||||
}
|
}
|
||||||
|
@@ -1,25 +1,38 @@
|
|||||||
import { reactive, ref } from "vue"
|
import { reactive, ref } from "vue"
|
||||||
|
|
||||||
import type { UserInfoResponseVO } from "@/swagger"
|
import type { UserInfoResponseVO } from "@/swagger"
|
||||||
|
|
||||||
export const globalStore = {
|
export const globalStore = reactive<{
|
||||||
currentUserInfo: ref<UserInfoResponseVO>({})
|
currentUserInfo?: UserInfoResponseVO
|
||||||
}
|
}>({})
|
||||||
|
|
||||||
export const siteSetting = {
|
export const siteSetting = reactive({
|
||||||
title: ref<string>("网站标题"),
|
keys: {
|
||||||
footer: ref<string>(""),
|
site: {
|
||||||
customNavigationMenu: ref<Array<{
|
title: "site.title",
|
||||||
|
navigation: "site.navigation",
|
||||||
|
css: "site.css",
|
||||||
|
footer: "site.footer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: "网站标题",
|
||||||
|
footer: "",
|
||||||
|
css: "",
|
||||||
|
navigation: ref<Array<{
|
||||||
url: string,
|
url: string,
|
||||||
text: string
|
text: string
|
||||||
}>>()
|
}>>(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export function loadGlobalStore() {
|
||||||
|
globalStore.currentUserInfo = JSON.parse(window.localStorage.getItem("currentUserInfo") || "{}")
|
||||||
|
console.log("local storage user info: ", globalStore.currentUserInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function load() {
|
export function saveGlobalStore() {
|
||||||
globalStore.currentUserInfo.value = JSON.parse(window.localStorage.getItem("currentUserInfo") || "{}")
|
if (globalStore.currentUserInfo?.id) {
|
||||||
console.log("local storage user info: ", globalStore.currentUserInfo.value)
|
window.localStorage.setItem("currentUserInfo", JSON.stringify(globalStore.currentUserInfo))
|
||||||
}
|
} else {
|
||||||
|
window.localStorage.removeItem("currentUserInfo")
|
||||||
export function save() {
|
}
|
||||||
window.localStorage.setItem("currentUserInfo", JSON.stringify(globalStore.currentUserInfo.value))
|
|
||||||
console.log(window.localStorage)
|
|
||||||
}
|
}
|
@@ -1,6 +1,19 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { siteSetting } from '@/api';
|
import { onMounted } from 'vue';
|
||||||
|
import { api, siteSetting } from '@/api';
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// 获取站点页脚
|
||||||
|
api.SettingController.getSettingContent(siteSetting.keys.site.footer)
|
||||||
|
.then(response => {
|
||||||
|
let vo = response.data;
|
||||||
|
if (vo.code === 200) {
|
||||||
|
let title = vo.data ?? ""
|
||||||
|
siteSetting.footer = title
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -13,7 +26,11 @@ import { siteSetting } from '@/api';
|
|||||||
|
|
|
|
||||||
<a href="https://editor.swagger.io/">Editor</a>
|
<a href="https://editor.swagger.io/">Editor</a>
|
||||||
</p>
|
</p>
|
||||||
<p>{{ siteSetting.footer.value }}</p>
|
<p>{{ siteSetting.footer }}</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
@@ -6,6 +6,7 @@ import { RouterLink } from 'vue-router'
|
|||||||
import { UserInfoResponseVORoleEnum } from "@/swagger";
|
import { UserInfoResponseVORoleEnum } from "@/swagger";
|
||||||
import { api, globalStore, siteSetting } from "@/api"
|
import { api, globalStore, siteSetting } from "@/api"
|
||||||
import { updateCurrentUserInfo } from '@/utils';
|
import { updateCurrentUserInfo } from '@/utils';
|
||||||
|
import router from '@/router';
|
||||||
|
|
||||||
const currentUserInfo = globalStore.currentUserInfo
|
const currentUserInfo = globalStore.currentUserInfo
|
||||||
const navigationMenu = siteSetting.customNavigationMenu
|
const navigationMenu = siteSetting.customNavigationMenu
|
||||||
@@ -14,53 +15,48 @@ const menuIndex = ref<string>(document.location.pathname)
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 获取站点标题
|
// 获取站点标题
|
||||||
api.SettingController.getSettingContent("site.title")
|
api.SettingController.getSettingContent(siteSetting.keys.site.title)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let vo = response.data;
|
let vo = response.data;
|
||||||
if (vo.code === 200) {
|
if (vo.code === 200) {
|
||||||
let title = vo.data ?? "网站标题"
|
let title = vo.data ?? "网站标题"
|
||||||
siteSetting.title.value = title
|
siteSetting.title = title
|
||||||
document.title = title
|
document.title = title
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 获取站点页脚
|
if (currentUserInfo?.id) {
|
||||||
api.SettingController.getSettingContent("site.footer")
|
|
||||||
.then(response => {
|
|
||||||
let vo = response.data;
|
|
||||||
if (vo.code === 200) {
|
|
||||||
let title = vo.data ?? ""
|
|
||||||
siteSetting.footer.value = title
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!currentUserInfo.value.id) {
|
|
||||||
// 获取当前登录的用户信息
|
// 获取当前登录的用户信息
|
||||||
updateCurrentUserInfo();
|
updateCurrentUserInfo();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function onSelectMenu(index: string) {
|
||||||
|
router.push(index)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-menu :default-active="menuIndex" mode="horizontal" :ellipsis="false">
|
<el-menu :default-active="menuIndex" mode="horizontal" :ellipsis="false" @select="onSelectMenu">
|
||||||
<el-menu-item index="/">
|
<el-menu-item index="/">
|
||||||
<router-link to="/">{{ siteSetting.title.value }}</router-link>
|
{{ siteSetting.title }}
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/tags">
|
<el-menu-item index="/tags">
|
||||||
<router-link to="/tags">标签</router-link>
|
标签
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item v-for="customMenu in navigationMenu">
|
<el-menu-item v-for="customMenu in navigationMenu" :index="customMenu.text">
|
||||||
<router-link :to="customMenu.url">{{ customMenu.text }}</router-link>
|
{{ customMenu.text }}
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
|
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
|
|
||||||
<el-menu-item index="/login" v-if="!currentUserInfo.id">
|
<el-menu-item index="/login" v-if="!currentUserInfo?.id">
|
||||||
<router-link to="/login">登录</router-link>
|
登录
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/register" v-if="!currentUserInfo.id">
|
<el-menu-item index="/register" v-if="!currentUserInfo?.id">
|
||||||
<router-link to="/register">注册</router-link>
|
注册
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/manage" v-if="currentUserInfo?.role === UserInfoResponseVORoleEnum.ADMIN">
|
<el-menu-item index="/manage" v-if="currentUserInfo?.role === UserInfoResponseVORoleEnum.ADMIN">
|
||||||
<router-link to="/manage">管理面板</router-link>
|
管理面板
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -2,14 +2,27 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { api, siteSetting } from '@/api';
|
import { api, siteSetting } from '@/api';
|
||||||
function changeSetting(id: string, content: string) {
|
function changeSetting(id: string, content: string) {
|
||||||
api.SettingController.updateSetting(content, id, { withCredentials: true })
|
api.SettingController.updateSetting({ content }, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeCustomCSS(cssText: string) {
|
||||||
|
let cssElement = document.getElementById("custom-css")
|
||||||
|
siteSetting.css = cssText
|
||||||
|
if (cssElement != null) cssElement.innerText = cssText
|
||||||
|
api.SettingController.updateSetting({ "content": cssText }, siteSetting.keys.site.css)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<el-input v-model="siteSetting.title.value" placeholder="网站标题"
|
<el-input v-model="siteSetting.title" placeholder="网站标题"
|
||||||
@change="changeSetting('site.title', siteSetting.title.value)" />
|
@change="changeSetting(siteSetting.keys.site.title, siteSetting.title)" show-word-limit maxlength="10" />
|
||||||
<el-input v-model="siteSetting.footer.value" placeholder="页脚文本"
|
<el-input v-model="siteSetting.footer" placeholder="页脚文本(支持HTML)"
|
||||||
@change="changeSetting('site.footer', siteSetting.footer.value)" />
|
@change="changeSetting(siteSetting.keys.site.footer, siteSetting.footer)" show-word-limit maxlength="1024" />
|
||||||
|
<el-input v-model="siteSetting.css" placeholder="自定义CSS" @change="changeCustomCSS(siteSetting.css)" type="textarea"
|
||||||
|
autosize />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
.el-input {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
@@ -20,6 +20,7 @@ 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
|
||||||
@@ -201,12 +202,12 @@ export const SettingControllerApiAxiosParamCreator = function (configuration?: C
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {string} body
|
* @param {SettingUpdateRequireVO} 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: string, id: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
updateSetting: async (body: SettingUpdateRequireVO, 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.');
|
||||||
@@ -227,7 +228,50 @@ 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'] = 'text/plain';
|
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 批量更改网站设置
|
||||||
|
* @param {{ [key: string]: string; }} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
updateSettings: async (body: { [key: string]: string; }, 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 updateSettings.');
|
||||||
|
}
|
||||||
|
const localVarPath = `/api/v1/settings/`;
|
||||||
|
// 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: 'PUT', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
const query = new URLSearchParams(localVarUrlObj.search);
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
for (const key in localVarQueryParameter) {
|
for (const key in localVarQueryParameter) {
|
||||||
@@ -316,18 +360,32 @@ export const SettingControllerApiFp = function(configuration?: Configuration) {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {string} body
|
* @param {SettingUpdateRequireVO} 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: string, id: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOVoid>>> {
|
async updateSetting(body: SettingUpdateRequireVO, 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};
|
||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 批量更改网站设置
|
||||||
|
* @param {{ [key: string]: string; }} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async updateSettings(body: { [key: string]: string; }, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ResponseVOVoid>>> {
|
||||||
|
const localVarAxiosArgs = await SettingControllerApiAxiosParamCreator(configuration).updateSettings(body, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -381,14 +439,24 @@ export const SettingControllerApiFactory = function (configuration?: Configurati
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {string} body
|
* @param {SettingUpdateRequireVO} 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: string, id: string, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
async updateSetting(body: SettingUpdateRequireVO, 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));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 批量更改网站设置
|
||||||
|
* @param {{ [key: string]: string; }} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async updateSettings(body: { [key: string]: string; }, options?: AxiosRequestConfig): Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
|
return SettingControllerApiFp(configuration).updateSettings(body, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -447,13 +515,24 @@ export class SettingControllerApi extends BaseAPI {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 更改网站设置
|
* @summary 更改网站设置
|
||||||
* @param {string} body
|
* @param {SettingUpdateRequireVO} 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: string, id: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
public async updateSetting(body: SettingUpdateRequireVO, 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));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 批量更改网站设置
|
||||||
|
* @param {{ [key: string]: string; }} body
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SettingControllerApi
|
||||||
|
*/
|
||||||
|
public async updateSettings(body: { [key: string]: string; }, options?: AxiosRequestConfig) : Promise<AxiosResponse<ResponseVOVoid>> {
|
||||||
|
return SettingControllerApiFp(this.configuration).updateSettings(body, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ 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';
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
@@ -1,16 +1,16 @@
|
|||||||
import { api, globalStore, save } from "@/api";
|
import { api, globalStore, saveGlobalStore } from "@/api";
|
||||||
|
|
||||||
|
|
||||||
export function updateCurrentUserInfo() {
|
export function updateCurrentUserInfo() {
|
||||||
api.UserController.getCurrentUserInfo({ withCredentials: true })
|
api.UserController.getCurrentUserInfo()
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
let vo = resp.data
|
let vo = resp.data
|
||||||
if (vo.code === 200) {
|
if (vo.code === 200) {
|
||||||
globalStore.currentUserInfo.value = vo.data || {}
|
globalStore.currentUserInfo = vo.data
|
||||||
console.log("current user info: ", vo.data)
|
console.log("current user info: ", vo.data)
|
||||||
} else {
|
} else {
|
||||||
console.error("ckeck current user info failed!")
|
globalStore.currentUserInfo = undefined
|
||||||
|
console.warn("ckeck current user info failed!")
|
||||||
}
|
}
|
||||||
save()
|
saveGlobalStore()
|
||||||
})
|
})
|
||||||
}
|
}
|
@@ -9,7 +9,7 @@ const form = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
api.UserController.loginUser(form, { withCredentials: true })
|
api.UserController.loginUser(form)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
let vo = resp.data;
|
let vo = resp.data;
|
||||||
if (vo.code === 200) {
|
if (vo.code === 200) {
|
||||||
@@ -31,7 +31,7 @@ const onSubmit = () => {
|
|||||||
<el-input v-model="form.email" />
|
<el-input v-model="form.email" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码">
|
<el-form-item label="密码">
|
||||||
<el-input v-model="form.password" type="password" />
|
<el-input v-model="form.password" type="password" show-password />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button class="login-button" type="primary" @click="onSubmit">登录</el-button>
|
<el-button class="login-button" type="primary" @click="onSubmit">登录</el-button>
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import SiteManageComponent from '@/components/manage/SiteManageComponent.vue';
|
import SiteManageComponent from '@/components/manage/SiteManageComponent.vue';
|
||||||
|
import { globalStore } from '@/api';
|
||||||
|
|
||||||
const activeName = ref<string>('site')
|
const activeName = ref<string>('site')
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!globalStore.currentUserInfo?.id) {
|
||||||
|
location.pathname = "/"
|
||||||
|
console.log("not login!")
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
Reference in New Issue
Block a user