sync: 同步 sql-platform-pro 最新代码 — 权限体系安全修复 v0.8.1

- P0: 实例访问控制全线接入权限组 (829测试)
- P1: permissions字段激活 + 操作级权限检查 (843测试)
- 前端: 删除数据权限页面, 权限组合并为唯一入口
- 新增: CodeMirror编辑器 + 查询模板 + 慢查询分析
- 新增: MongoDB管理页面 + Dashboard增强
- 修复: Pydantic V2迁移 + 前端TS错误修复
This commit is contained in:
logan committed 2026-05-23 14:41:06 +08:00
1 parent 6fcd9465cf
commit 4c9427e546
105 files changed
+23680 -471

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import request from './request';
export var mongoApi = {
getDatabases: function (id: number) {
return request.get('/mongo/' + id + '/databases');
},
getCollections: function (id: number, database: string) {
return request.get('/mongo/' + id + '/databases/' + encodeURIComponent(database) + '/collections');
},
getCollectionStats: function (id: number, collection: string, database?: string) {
var params: Record<string, any> = {};
if (database) { params.database = database; }
return request.get('/mongo/' + id + '/collections/' + encodeURIComponent(collection) + '/stats', { params: params });
},
query: function (id: number, data: Record<string, any>) {
return request.post('/mongo/' + id + '/query', data);
},
execute: function (id: number, data: Record<string, any>) {
return request.post('/mongo/' + id + '/execute', data);
},
testConnection: function (id: number) {
return request.post('/mongo/' + id + '/test-connection');
},
};
+28 -2
View File
@@ -10,16 +10,42 @@ request.interceptors.request.use((config) => {
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
// Debug logging
console.log(
`[API] ${config.method?.toUpperCase()} ${config.baseURL}${config.url}`,
config.params ? 'params=' + JSON.stringify(config.params) : '',
config.data ? 'data=' + JSON.stringify(config.data).substring(0, 200) : ''
);
return config;
});
request.interceptors.response.use(
(response) => response.data,
(response) => {
console.log(
`[API] ${response.status} ${response.config.url}`,
Array.isArray(response.data) ? `(${response.data.length} items)` : ''
);
return response.data;
},
(error) => {
if (error.response?.status === 401) {
const status = error.response?.status;
const url = error.config?.url;
const detail = error.response?.data?.detail;
if (status === 401) {
console.warn(`[API] 401 Unauthorized: ${url} — redirecting to login`);
localStorage.removeItem('token');
window.location.href = '/login';
} else if (status === 500) {
console.error(`[API] 500 Internal Error: ${url}`, detail || error.message);
} else if (status === 422) {
console.warn(`[API] 422 Validation Error: ${url}`, error.response?.data);
} else {
console.warn(`[API] ${status || 'NETWORK'} Error: ${url}`, detail || error.message);
}
return Promise.reject(error);
}
);
+17
View File
@@ -0,0 +1,17 @@
import request from './request';
export const slowLogApi = {
list: (instanceId: number) =>
request.get<any, any>(`/slow-logs/instances/${instanceId}`),
collect: (instanceId: number, database: string = '', limit: number = 50) =>
request.post<any, any>(`/slow-logs/instances/${instanceId}/collect`, null, {
params: { database, limit },
}),
report: (instanceId: number) =>
request.get<any, any>(`/slow-logs/instances/${instanceId}/report`),
topQueries: () =>
request.get<any, any>('/slow-logs/dashboard/top'),
};