mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 02:06:37 +08:00
refactor(frontend): colocate admin components and split service layer
Move route-specific admin components from components/common/admin into app/(main)/admin/<feature>/components/. Split AdminService god object into domain services, fix UploadService to use BaseService, add AdminUploadService, consolidate DB export into DbManageService, and migrate consumers to the unified services entry.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import type {InternalAxiosRequestConfig} from 'axios';
|
||||
|
||||
import apiClient from '@/lib/services/core/api-client';
|
||||
import {BaseService} from '@/lib/services/core';
|
||||
import type {DBOverview, ExecuteSQLResponse, TableDataResponse} from './types';
|
||||
|
||||
@@ -38,4 +41,22 @@ export class DbManageService extends BaseService {
|
||||
static async executeSQL(sql: string): Promise<ExecuteSQLResponse> {
|
||||
return this.post<ExecuteSQLResponse>('/query', { sql });
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据库备份(SQLite .db / PostgreSQL .sql)
|
||||
*/
|
||||
static async exportDatabase(): Promise<{ blob: Blob; filename: string }> {
|
||||
const response = await apiClient.get<Blob>('/api/v1/admin/db-export', {
|
||||
withCredentials: true,
|
||||
responseType: 'blob',
|
||||
} as InternalAxiosRequestConfig);
|
||||
|
||||
const disposition = response.headers['content-disposition'] as string | undefined;
|
||||
let filename = 'wavelet_export';
|
||||
if (disposition) {
|
||||
const match = disposition.match(/filename="?([^";]+)"?/);
|
||||
if (match) filename = match[1];
|
||||
}
|
||||
return { blob: response.data, filename };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user