BUG fix: createdTopic, request

This commit is contained in:
KUN1007 2023-10-03 21:29:07 +08:00
parent fe74035f49
commit 6c4c575d6e
3 changed files with 8 additions and 5 deletions

View file

@ -12,7 +12,7 @@ const isEditUpdateTopicData = (data: any): data is EditUpdateTopicRequestData =>
export const checkTopicPublish = (
textCount: number,
topicData: EditCreateTopicRequestData | EditUpdateTopicRequestData
) => {
): boolean => {
// 检查 tid
if (isEditUpdateTopicData(topicData)) {
// 话题 id 为零,应该。。。。不存在吧(
@ -37,11 +37,13 @@ export const checkTopicPublish = (
}
if (textCount > 100007) {
message('Content max length is 100007!', '内容最大长度为100007', 'warn')
return false
}
// 检查 tag
if (!topicData.tags.length) {
message('Please use at least one tag!', '请至少使用一个标签!', 'warn')
return false
}
// 检查分类
@ -51,6 +53,7 @@ export const checkTopicPublish = (
'请至少选择一个分类!',
'warn'
)
return false
}
// 都通过则返回真

View file

@ -5,6 +5,8 @@ import { onRequestError } from '@/error/onRequestError'
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'
const successResponseArray = [200, 201, 202, 204, 205, 206]
export type FetchOptions = {
method: HttpMethod
credentials: 'include'
@ -28,8 +30,8 @@ const kunFetchRequest = async <T>(
const response = await fetch(fullUrl, { ...options, headers })
// 后端的一切正常响应都被设为 200 了
if (response.status != 200) {
// 不为 20X 则报错
if (!successResponseArray.includes(response.status)) {
// 处理错误token 过期
await onRequestError(response)
throw new Error('KUNGalgame Fetch Error occurred, but no problem')

View file

@ -37,8 +37,6 @@ const handlePublish = async () => {
messageStore.info('AlertInfo.edit.publishSuccess')
//
useKUNGalgameEditStore().resetTopicData()
} else {
message('Failed to create new topic', '发布话题失败', 'error')
}
} else {
messageStore.info('AlertInfo.edit.publishCancel')