-
Notifications
You must be signed in to change notification settings - Fork 57
Improve Account admin page titles and list URLs #3315
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,24 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from 'vue' | ||
| import { computed } from 'vue' | ||
|
|
||
| import { useQuery } from '@/utils/query' | ||
| import { useRouteQueryParamInt, useRouteQueryParamStr, useRouteQueryParamStrEnum } from '@/utils/route' | ||
| import { usePageTitle } from '@/utils/utils' | ||
| import { UIButton, UIError, UILoading, UIPagination, UISelect, UISelectOption } from '@/components/ui' | ||
| import * as auditApis from '@/apis/admin/audit' | ||
| import { formatJSON, formatTime } from './common' | ||
|
|
||
| const pageSize = 20 | ||
| const page = ref(1) | ||
| const sortOrder = ref<'asc' | 'desc'>('desc') | ||
| const createdAfter = ref('') | ||
| const createdBefore = ref('') | ||
| const SortOrder = { | ||
| Asc: 'asc', | ||
| Desc: 'desc' | ||
| } as const | ||
|
|
||
| watch([sortOrder, createdAfter, createdBefore], () => { | ||
| page.value = 1 | ||
| }) | ||
| const pageSize = 20 | ||
| const page = useRouteQueryParamInt('p', 1) | ||
| const resetPage = (query: Partial<Record<string, string | null>>) => ({ ...query, p: null }) | ||
| const sortOrder = useRouteQueryParamStrEnum('order', SortOrder, SortOrder.Desc, resetPage) | ||
| const createdAfter = useRouteQueryParamStr('from', '', resetPage) | ||
| const createdBefore = useRouteQueryParamStr('to', '', resetPage) | ||
|
Comment on lines
+16
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Synchronously setting both To fix this, define function clearFilters() {
router.push({
query: {
...router.currentRoute.value.query,
from: undefined,
to: undefined,
p: undefined
}
})
} |
||
|
|
||
| function clearFilters() { | ||
| createdAfter.value = '' | ||
|
|
@@ -44,6 +48,8 @@ const auditLogsQuery = useQuery( | |
| ) | ||
|
|
||
| const pageTotal = computed(() => Math.ceil((auditLogsQuery.data.value?.total ?? 0) / pageSize)) | ||
|
|
||
| usePageTitle({ en: 'Account admin audit logs', zh: '账号管理审计日志' }) | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import
useRouterfromvue-routerto allow batch updating the route query parameters inclearFiltersand avoid race conditions.