Merge pull request '同步dev分支进度,可以开始2.0开发了' (#2) from dev into main
Reviewed-on: #2
This commit is contained in:
commit
2b9c0c60c6
@ -45,7 +45,7 @@ public class FlowLimitingFilter extends HttpFilter {
|
|||||||
@Override
|
@Override
|
||||||
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
String address = request.getRemoteAddr();
|
String address = request.getRemoteAddr();
|
||||||
if (!tryCount(address))
|
if (!"OPTIONS".equals(request.getMethod()) && !tryCount(address))
|
||||||
this.writeBlockMessage(response);
|
this.writeBlockMessage(response);
|
||||||
else
|
else
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
@ -72,9 +72,9 @@ public class FlowLimitingFilter extends HttpFilter {
|
|||||||
* @throws IOException 可能的异常
|
* @throws IOException 可能的异常
|
||||||
*/
|
*/
|
||||||
private void writeBlockMessage(HttpServletResponse response) throws IOException {
|
private void writeBlockMessage(HttpServletResponse response) throws IOException {
|
||||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
response.setStatus(429);
|
||||||
response.setContentType("application/json;charset=utf-8");
|
response.setContentType("application/json;charset=utf-8");
|
||||||
PrintWriter writer = response.getWriter();
|
PrintWriter writer = response.getWriter();
|
||||||
writer.write(RestBean.forbidden("操作频繁,请稍后再试").asJsonString());
|
writer.write(RestBean.failure(429, "请求频率过快,请稍后再试").asJsonString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,45 +146,43 @@ const editorOption = {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<el-drawer direction="btt" :model-value="show"
|
||||||
<el-drawer direction="btt" :model-value="show"
|
:size="650" @open="initEditor"
|
||||||
:size="650" @open="initEditor"
|
@close="emit('close')"
|
||||||
@close="emit('close')"
|
:show-close="false">
|
||||||
:show-close="false">
|
<template #header>
|
||||||
<template #header>
|
<div>
|
||||||
<div>
|
<div style="font-weight: bold">发表新的帖子</div>
|
||||||
<div style="font-weight: bold">发表新的帖子</div>
|
<div style="font-size: 13px">发表您的内容之前,请遵守相关法律法规,不要出现骂人爆粗口这种不文明行为。</div>
|
||||||
<div style="font-size: 13px">发表您的内容之前,请遵守相关法律法规,不要出现骂人爆粗口这种不文明行为。</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<div style="display: flex;gap: 10px">
|
||||||
<div style="display: flex;gap: 10px">
|
<div style="width: 120px">
|
||||||
<div style="width: 120px">
|
<el-select placeholder="选择类型..." v-model="editor.type" :disabled="!store.forum.types.length">
|
||||||
<el-select placeholder="选择类型..." v-model="editor.type" :disabled="!store.forum.types.length">
|
<el-option v-for="item in store.forum.types" :value="item.id" :label="item.name"/>
|
||||||
<el-option v-for="item in store.forum.types" :value="item.id" :label="item.name"/>
|
</el-select>
|
||||||
</el-select>
|
</div>
|
||||||
</div>
|
<div style="flex: 1">
|
||||||
<div style="flex: 1">
|
<el-input maxlength="30" placeholder="请输入帖子标题..."
|
||||||
<el-input maxlength="30" placeholder="请输入帖子标题..."
|
:prefix-icon="Document" v-model="editor.title"/>
|
||||||
:prefix-icon="Document" v-model="editor.title"/>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="margin-top: 15px;height: 450px;border-radius: 5px;overflow: hidden"
|
|
||||||
v-loading="editor.uploading"
|
|
||||||
element-loading-text="正在上传图片,请稍后...">
|
|
||||||
<quill-editor ref="refEditor" v-model:content="editor.text"
|
|
||||||
:options="editorOption" content-type="delta"
|
|
||||||
style="height: calc(100% - 44px)"/>
|
|
||||||
</div>
|
|
||||||
<div style="display: flex;justify-content: space-between;margin-top: 10px">
|
|
||||||
<div style="color: grey;font-size: 13px">
|
|
||||||
当前字数: {{ contentLength }}(最大支持20000字)
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<el-button @click="submitTopic" type="success" plain>{{submitButton}}</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-drawer>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-top: 15px;height: 450px;border-radius: 5px;overflow: hidden"
|
||||||
|
v-loading="editor.uploading"
|
||||||
|
element-loading-text="正在上传图片,请稍后...">
|
||||||
|
<quill-editor ref="refEditor" v-model:content="editor.text"
|
||||||
|
:options="editorOption" content-type="delta"
|
||||||
|
style="height: calc(100% - 44px)"/>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex;justify-content: space-between;margin-top: 10px">
|
||||||
|
<div style="color: grey;font-size: 13px">
|
||||||
|
当前字数: {{ contentLength }}(最大支持20000字)
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button @click="submitTopic" type="success" plain>{{submitButton}}</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
import router from "@/router";
|
||||||
|
|
||||||
const authItemName = "authorize"
|
const authItemName = "authorize"
|
||||||
|
|
||||||
@ -11,7 +12,12 @@ const accessHeader = () => {
|
|||||||
|
|
||||||
const defaultError = (error) => {
|
const defaultError = (error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
ElMessage.error('发生了一些错误,请联系管理员')
|
const status = error.response.status
|
||||||
|
if (status === 429) {
|
||||||
|
ElMessage.error(error.response.data.message)
|
||||||
|
} else {
|
||||||
|
ElMessage.error('发生了一些错误,请联系管理员')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultFailure = (message, status, url) => {
|
const defaultFailure = (message, status, url) => {
|
||||||
@ -43,26 +49,37 @@ function storeAccessToken(remember, token, expire){
|
|||||||
sessionStorage.setItem(authItemName, str)
|
sessionStorage.setItem(authItemName, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAccessToken() {
|
function deleteAccessToken(redirect = false) {
|
||||||
localStorage.removeItem(authItemName)
|
localStorage.removeItem(authItemName)
|
||||||
sessionStorage.removeItem(authItemName)
|
sessionStorage.removeItem(authItemName)
|
||||||
|
if(redirect) {
|
||||||
|
router.push({ name: 'welcome-login' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function internalPost(url, data, headers, success, failure, error = defaultError){
|
function internalPost(url, data, headers, success, failure, error = defaultError){
|
||||||
axios.post(url, data, { headers: headers }).then(({data}) => {
|
axios.post(url, data, { headers: headers }).then(({data}) => {
|
||||||
if(data.code === 200)
|
if(data.code === 200) {
|
||||||
success(data.data)
|
success(data.data)
|
||||||
else
|
} else if(data.code === 401) {
|
||||||
|
failure('登录状态已过期,请重新登录!')
|
||||||
|
deleteAccessToken(true)
|
||||||
|
} else {
|
||||||
failure(data.message, data.code, url)
|
failure(data.message, data.code, url)
|
||||||
|
}
|
||||||
}).catch(err => error(err))
|
}).catch(err => error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
function internalGet(url, headers, success, failure, error = defaultError){
|
function internalGet(url, headers, success, failure, error = defaultError){
|
||||||
axios.get(url, { headers: headers }).then(({data}) => {
|
axios.get(url, { headers: headers }).then(({data}) => {
|
||||||
if(data.code === 200)
|
if(data.code === 200) {
|
||||||
success(data.data)
|
success(data.data)
|
||||||
else
|
} else if(data.code === 401) {
|
||||||
|
failure('登录状态已过期,请重新登录!')
|
||||||
|
deleteAccessToken(true)
|
||||||
|
} else {
|
||||||
failure(data.message, data.code, url)
|
failure(data.message, data.code, url)
|
||||||
|
}
|
||||||
}).catch(err => error(err))
|
}).catch(err => error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import {get} from "@/net";
|
|||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
import TopicEditor from "@/components/TopicEditor.vue";
|
import TopicEditor from "@/components/TopicEditor.vue";
|
||||||
import {useStore} from "@/store";
|
import {useStore} from "@/store";
|
||||||
import axios from "axios";
|
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import TopicCollectList from "@/components/TopicCollectList.vue";
|
import TopicCollectList from "@/components/TopicCollectList.vue";
|
||||||
import TopicTag from "@/components/TopicTag.vue";
|
import TopicTag from "@/components/TopicTag.vue";
|
||||||
@ -95,7 +94,7 @@ navigator.geolocation.getCurrentPosition(position => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div style="display: flex;margin: 20px auto;gap: 20px;max-width: 1000px">
|
<div style="display: flex;margin: 20px auto;gap: 20px;max-width: 1000px;padding: 0 20px">
|
||||||
<div style="flex: 1">
|
<div style="flex: 1">
|
||||||
<light-card>
|
<light-card>
|
||||||
<div class="edit-topic">
|
<div class="edit-topic">
|
||||||
@ -222,9 +221,6 @@ navigator.geolocation.getCurrentPosition(position => {
|
|||||||
<div class="friend-link">
|
<div class="friend-link">
|
||||||
<el-image src="https://element-plus.org/images/vform-banner.png" style="height: 100%"/>
|
<el-image src="https://element-plus.org/images/vform-banner.png" style="height: 100%"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="friend-link">
|
|
||||||
<el-image src="https://element-plus.org/images/sponsors/jnpfsoft.jpg" style="height: 100%"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user