Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -506,17 +506,26 @@ export function useTable() {
const getTableData = (params: IDefinitionParam) => {
if (variables.loadingRef) return
variables.loadingRef = true
const { state } = useAsyncState(
queryListPaging({ ...params }, variables.projectCode).then((res: any) => {
// Always release loading lock, even when request fails.
const queryStatePromise = queryListPaging(
{ ...params },
variables.projectCode
)
.then((res: any) => {
variables.totalCount = res.total
variables.totalPage = res.totalPage
variables.tableData = res.totalList.map((item: any) => {
return { ...item }
})
})
.catch((err: Error) => {
window.$message.error(err?.message || 'Request failed')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use i18n to show message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I’ve updated the error message to use i18n instead of a hardcoded string, and added corresponding locale entries in both en_US and zh_CN.

})
.finally(() => {
variables.loadingRef = false
}),
{ total: 0, table: [] }
)
})

const { state } = useAsyncState(queryStatePromise, { total: 0, table: [] })
return state
}

Expand Down
Loading