From 7fcaa32db4940ff9ca42b961b00c453b496d8d25 Mon Sep 17 00:00:00 2001 From: ahe <53739884+qhmhyp@users.noreply.github.com> Date: Fri, 16 Oct 2026 11:54:50 +0800 Subject: [PATCH] fix(accounts): persist platform and status filters --- frontend/src/views/admin/AccountsView.vue | 41 +++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/admin/AccountsView.vue b/frontend/src/views/admin/AccountsView.vue index 2502f2db8c..6d71337fdd 100644 --- a/frontend/src/views/admin/AccountsView.vue +++ b/frontend/src/views/admin/AccountsView.vue @@ -496,6 +496,7 @@ import { useI18n } from 'vue-i18n' import { useAppStore } from '@/stores/app' import { useAuthStore } from '@/stores/auth' import { adminAPI } from '@/api/admin' +import { CONCRETE_PLATFORM_OPTIONS } from '@/constants/platforms' import { useTableLoader } from '@/composables/useTableLoader' import { useSwipeSelect, type SwipeSelectVirtualContext } from '@/composables/useSwipeSelect' import { useTableSelection } from '@/composables/useTableSelection' @@ -653,6 +654,31 @@ const HIDDEN_COLUMNS_KEY = 'account-hidden-columns' const HIDDEN_COLUMNS_VERSION_KEY = 'account-hidden-columns-version' const HIDDEN_COLUMNS_CURRENT_VERSION = 'scheduler-score-hidden-by-default' +// Account filter settings +const ACCOUNT_FILTER_STORAGE_KEY = 'account-filter-values' +type AccountFilterValues = { + platform: string + status: string +} +const loadInitialAccountFilterValues = (): AccountFilterValues => { + const fallback: AccountFilterValues = { platform: '', status: '' } + try { + const raw = localStorage.getItem(ACCOUNT_FILTER_STORAGE_KEY) + if (!raw) return fallback + const parsed: unknown = JSON.parse(raw) + if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return fallback + const values = parsed as Record + return { + platform: typeof values.platform === 'string' && CONCRETE_PLATFORM_OPTIONS.some(option => option.value === values.platform) + ? values.platform : '', + status: typeof values.status === 'string' && ['active', 'inactive', 'error', 'rate_limited', 'temp_unschedulable', 'unschedulable'].includes(values.status) + ? values.status : '' + } + } catch { + return fallback + } +} + // Sorting settings const ACCOUNT_SORT_STORAGE_KEY = 'account-table-sort' type AccountSortOrder = 'asc' | 'desc' @@ -1084,9 +1110,8 @@ const { } = useTableLoader({ fetchFn: adminAPI.accounts.list, initialParams: { - platform: '', + ...loadInitialAccountFilterValues(), type: '', - status: '', privacy_mode: '', group: '', search: '', @@ -1292,7 +1317,19 @@ const refreshUpstreamBillingSortedList = async (force = false) => { useIntervalFn(() => { void refreshUpstreamBillingRates() }, 5 * 60_000, { immediate: false }) +const saveAccountFilterValues = () => { + try { + localStorage.setItem(ACCOUNT_FILTER_STORAGE_KEY, JSON.stringify({ + platform: params.platform, + status: params.status + })) + } catch { + // Filtering must remain available when browser storage is unavailable. + } +} + const debouncedReload = () => { + saveAccountFilterValues() clearSelection() syncAccountListDerivedParams() hasPendingListSync.value = false