Add personal tool management page

This commit is contained in:
2024-01-30 13:33:57 +08:00
parent ad47030cb2
commit 0e804ff732
12 changed files with 457 additions and 61 deletions

View File

@@ -68,11 +68,14 @@ service.interceptors.response.use(
switch (response.data.code) {
case PERMISSION_UNAUTHORIZED:
removeToken()
void message.error(
<>
<strong></strong>
</>
)
void message.error({
content: (
<>
<strong></strong>
</>
),
key: 'NO_LOGIN'
})
setTimeout(() => {
location.reload()
}, 1500)
@@ -80,11 +83,14 @@ service.interceptors.response.use(
case PERMISSION_TOKEN_ILLEGAL:
case PERMISSION_TOKEN_HAS_EXPIRED:
removeToken()
void message.error(
<>
<strong></strong>
</>
)
void message.error({
content: (
<>
<strong></strong>
</>
),
key: 'LOGIN_HAS_EXPIRED'
})
setTimeout(() => {
location.replace(
getRedirectUrl('/login', `${location.pathname}${location.search}`)
@@ -92,18 +98,24 @@ service.interceptors.response.use(
}, 1500)
throw response?.data
case PERMISSION_ACCESS_DENIED:
void message.error(
<>
<strong></strong>
</>
)
void message.error({
content: (
<>
<strong></strong>
</>
),
key: 'ACCESS_DENIED'
})
throw response?.data
case SYSTEM_REQUEST_TOO_FREQUENT:
void message.warning(
<>
<strong></strong>
</>
)
void message.warning({
content: (
<>
<strong></strong>
</>
),
key: 'REQUEST_TOO_FREQUENT'
})
throw response?.data
}
return response
@@ -113,13 +125,16 @@ service.interceptors.response.use(
error.code === 'ETIMEDOUT' ||
(error.code === 'ECONNABORTED' && error.message.includes('timeout'))
) {
void message.error('请求超时,请稍后重试')
void message.error({ content: '请求超时,请稍后重试', key: 'TIMEOUT' })
} else {
void message.error(
<>
<strong></strong>
</>
)
void message.error({
content: (
<>
<strong></strong>
</>
),
key: 'SERVER_ERROR'
})
}
return await Promise.reject(error?.response?.data)
}

View File

@@ -1,5 +1,10 @@
import request from '@/services/index'
import { URL_TOOL, URL_TOOL_CATEGORY, URL_TOOL_TEMPLATE } from '@/constants/urls.constants'
import {
URL_TOOL,
URL_TOOL_CATEGORY,
URL_TOOL_DETAIL,
URL_TOOL_TEMPLATE
} from '@/constants/urls.constants'
export const r_tool_template_get = () => request.get<ToolTemplateVo[]>(URL_TOOL_TEMPLATE)
@@ -9,3 +14,8 @@ export const r_tool_template_get_one = (id: string) =>
export const r_tool_category_get = () => request.get<ToolCategoryVo[]>(URL_TOOL_CATEGORY)
export const r_tool_create = (param: ToolCreateParam) => request.post<ToolVo>(URL_TOOL, param)
export const r_tool_get = () => request.get<ToolVo[]>(URL_TOOL)
export const r_tool_detail = (username: string, toolId: string, ver: string) =>
request.get<ToolVo>(`${URL_TOOL_DETAIL}/${username}/${toolId}/${ver}`)