BUG fix: createdTopic, request
This commit is contained in:
parent
6269037d5b
commit
cc4a69826f
|
@ -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
|
||||
}
|
||||
|
||||
// 都通过则返回真
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue