优化
This commit is contained in:
@@ -104,4 +104,38 @@ describe('API error diagnostics', () => {
|
||||
expect(refresh).toHaveBeenCalledTimes(1)
|
||||
expect(expired).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('refreshes once and replays the original request with the rotated access token', async () => {
|
||||
const refresh = vi.fn(async () => 'access-rotated')
|
||||
const expired = vi.fn()
|
||||
let orderRequests = 0
|
||||
registerAuthRefreshHandler(refresh)
|
||||
registerAuthSessionExpiredHandler(expired)
|
||||
http.defaults.adapter = async (config) => {
|
||||
if (config.url === '/platform/v1/orders' && orderRequests++ === 0) {
|
||||
throw new axios.AxiosError('Unauthorized', 'ERR_BAD_REQUEST', config, undefined, {
|
||||
status: 401,
|
||||
statusText: 'Unauthorized',
|
||||
headers: {},
|
||||
config,
|
||||
data: { code: 'A0401', message: '登录状态已过期' },
|
||||
})
|
||||
}
|
||||
return {
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {},
|
||||
config,
|
||||
data: { code: '200', message: 'success', data: [{ id: 'order-1' }] },
|
||||
}
|
||||
}
|
||||
|
||||
const response = await http.get('/platform/v1/orders')
|
||||
|
||||
expect(refresh).toHaveBeenCalledTimes(1)
|
||||
expect(expired).not.toHaveBeenCalled()
|
||||
expect(orderRequests).toBe(2)
|
||||
expect(response.config.headers.Authorization).toBe('Bearer access-rotated')
|
||||
expect(response.data).toEqual([{ id: 'order-1' }])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -163,4 +163,18 @@ describe('DataTable column preferences', () => {
|
||||
expect(toolbarActions.find('.data-table__utility-actions').exists()).toBe(true)
|
||||
expect(toolbarActions.find('button[aria-label="列设置"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('can hide column settings for compact tables without leaving an empty toolbar', () => {
|
||||
const wrapper = shallowMount(DataTable, {
|
||||
props: { data: [], columns: configurableColumns, preferenceKey: 'summary-table', showColumnSettings: false },
|
||||
global: {
|
||||
provide: { [UI_PREFERENCE_SCOPE as symbol]: computed(() => 'user-1') },
|
||||
stubs: { ElTable: TableStub, ElTableColumn: ColumnStub, ElButton: ButtonStub, ElPopover: PopoverStub },
|
||||
directives: { loading: {} },
|
||||
},
|
||||
})
|
||||
|
||||
expect(wrapper.find('button[aria-label="列设置"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.data-table__toolbar').exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -63,11 +63,13 @@ const props = withDefaults(defineProps<{
|
||||
total?: number
|
||||
pageSizes?: number[]
|
||||
preferenceKey?: string
|
||||
showColumnSettings?: boolean
|
||||
}>(), {
|
||||
loading: false,
|
||||
emptyText: '暂无数据',
|
||||
total: undefined,
|
||||
pageSizes: () => [10, 20, 50, 100],
|
||||
showColumnSettings: true,
|
||||
})
|
||||
|
||||
const page = defineModel<number>('page', { default: 1 })
|
||||
@@ -76,7 +78,7 @@ const slots = useSlots()
|
||||
const preferenceScope = inject(UI_PREFERENCE_SCOPE, computed(() => 'anonymous'))
|
||||
const preference = ref<LayoutPreferenceSnapshot>({ version: 1, order: [], hidden: [] })
|
||||
const tableRef = ref<{ doLayout: () => void }>()
|
||||
const preferenceEnabled = computed(() => Boolean(props.preferenceKey))
|
||||
const preferenceEnabled = computed(() => Boolean(props.preferenceKey && props.showColumnSettings))
|
||||
|
||||
function columnId(column: DataTableColumn) {
|
||||
const value = column.key ?? column.columnKey ?? column.prop ?? column.property
|
||||
|
||||
Reference in New Issue
Block a user