mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 23:56:37 +08:00
fix(frontend): correct Pages deployment files route
Align the Pages deployment file-list request with the backend route and add a regression test.
This commit is contained in:
@@ -21,6 +21,10 @@ sidebar: false
|
|||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复 Pages 部署文件清单前端请求路径与后端路由不一致导致的 404 错误。
|
||||||
|
|
||||||
## [v3.2.0] - 2026-07-12
|
## [v3.2.0] - 2026-07-12
|
||||||
|
|
||||||
### 新增
|
### 新增
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ function DeploymentFilesPanel({
|
|||||||
}) {
|
}) {
|
||||||
const filesQuery = useQuery({
|
const filesQuery = useQuery({
|
||||||
queryKey: deploymentFilesQueryKey(projectId, deployment.id),
|
queryKey: deploymentFilesQueryKey(projectId, deployment.id),
|
||||||
queryFn: () => PagesService.listDeploymentFiles(projectId, deployment.id),
|
queryFn: () => PagesService.listDeploymentFiles(deployment.id),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (filesQuery.isLoading) {
|
if (filesQuery.isLoading) {
|
||||||
|
|||||||
@@ -44,11 +44,10 @@ export class PagesService extends OpenFlareBaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static listDeploymentFiles(
|
static listDeploymentFiles(
|
||||||
projectId: number,
|
|
||||||
deploymentId: number,
|
deploymentId: number,
|
||||||
): Promise<PagesDeploymentFile[]> {
|
): Promise<PagesDeploymentFile[]> {
|
||||||
return this.get<PagesDeploymentFile[]>(
|
return this.get<PagesDeploymentFile[]>(
|
||||||
`/${projectId}/deployments/${deploymentId}/files`,
|
`/deployments/${deploymentId}/files`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||||
|
import type {AxiosResponse} from 'axios';
|
||||||
|
|
||||||
|
import apiClient from '@/lib/services/core/api-client';
|
||||||
|
import {PagesService} from '@/lib/services/openflare/pages.service';
|
||||||
|
|
||||||
|
vi.mock('@/lib/services/core/api-client', () => ({
|
||||||
|
default: {
|
||||||
|
get: vi.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('PagesService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.mocked(apiClient.get).mockReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('requests deployment files using the backend deployment route', async () => {
|
||||||
|
vi.mocked(apiClient.get).mockResolvedValue({
|
||||||
|
data: {error_msg: '', data: []},
|
||||||
|
status: 200,
|
||||||
|
statusText: 'OK',
|
||||||
|
headers: {},
|
||||||
|
config: {headers: {}},
|
||||||
|
} as AxiosResponse);
|
||||||
|
|
||||||
|
await PagesService.listDeploymentFiles(7);
|
||||||
|
|
||||||
|
expect(apiClient.get).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/d/pages/deployments/7/files',
|
||||||
|
expect.objectContaining({params: undefined}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user