Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复默认attachment翻页无效问题 #518

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 13 additions & 3 deletions web/src/components/ma-resource-picker/panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ const selected = ref<Resource[]>([])

async function getResourceList(params: Resource = {}) {
loading.value = true
const { pageNo, pageSize, ...restParams } = params
const queryParams = {
page: pageNo,
page_size: pageSize,
...restParams,
}
const { data } = await useHttp().get(
'/admin/attachment/list',
{ params: Object.assign({ pageSize: props.pageSize }, params) },
{ params: Object.assign({ page_size: props.pageSize }, queryParams) },
)
total.value = data.total
resources.value = data.list
Expand Down Expand Up @@ -362,7 +368,11 @@ function executeContextmenu(e: MouseEvent, resource: Resource) {
],
})
}

function handleChangePage(currentPage: number, pageSize: number) {
queryParams.value.pageNo = currentPage
Copy link
Member

Choose a reason for hiding this comment

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

pageNo 是什么

Copy link
Contributor Author

Choose a reason for hiding this comment

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

前端代码之前翻页标记就是pageNo 我怕直接改了影响其他用调用就在只在请求这里替换了

Copy link
Member

Choose a reason for hiding this comment

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

所有的翻页统一都用 page(当前页码) page_size (每页页数) 之前是 pageNo 那应该是写错了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

那等周末X.Mo提吧

queryParams.value.pageSize = pageSize
getResourceList(queryParams.value)
}
onMounted(async () => {
await getResourceList()
})
Expand Down Expand Up @@ -474,7 +484,7 @@ onMounted(async () => {
</el-tag>
<el-pagination
v-model:current-page="queryParams.pageNo" :disabled="loading" :total="total"
:page-size="queryParams.pageSize" background layout="prev, pager, next" :pager-count="5"
:page-size="queryParams.pageSize" background layout="prev, pager, next" :pager-count="5" @change="handleChangePage"
/>
</div>
<div v-if="props.showAction">
Expand Down
14 changes: 8 additions & 6 deletions web/src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ http.interceptors.request.use(
},
)

let isLogout = false

http.interceptors.response.use(
async (response: AxiosResponse): Promise<any> => {
isLoading.value = false
Expand All @@ -72,14 +74,14 @@ http.interceptors.response.use(
else {
switch (response?.data?.code) {
case ResultCode.UNAUTHORIZED: {
const logout = useDebounceFn(
async () => {
const logout = async () => {
if (isLogout === false) {
isLogout = true
setTimeout(() => isLogout = false, 5000)
Message.error('登录状态已过期,需要重新登录', { zIndex: 9999 })
await useUserStore().logout()
},
3000,
{ maxWait: 5000 },
)
}
}
// 检查token是否需要刷新
if (userStore.isLogin && !isRefreshToken.value) {
isRefreshToken.value = true
Expand Down
Loading