🎉 重构前端代码.
This commit is contained in:
54
orion-visor-ui/src/api/terminal/command-snippet-group.ts
Normal file
54
orion-visor-ui/src/api/terminal/command-snippet-group.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { CommandSnippetQueryResponse } from './command-snippet';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 命令片段分组创建请求
|
||||
*/
|
||||
export interface CommandSnippetGroupCreateRequest {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令片段分组更新请求
|
||||
*/
|
||||
export interface CommandSnippetGroupUpdateRequest extends CommandSnippetGroupCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令片段分组查询响应
|
||||
*/
|
||||
export interface CommandSnippetGroupQueryResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
items: Array<CommandSnippetQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建命令片段分组
|
||||
*/
|
||||
export function createCommandSnippetGroup(request: CommandSnippetGroupCreateRequest) {
|
||||
return axios.post('/terminal/command-snippet-group/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新命令片段分组
|
||||
*/
|
||||
export function updateCommandSnippetGroup(request: CommandSnippetGroupUpdateRequest) {
|
||||
return axios.put('/terminal/command-snippet-group/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部命令片段分组
|
||||
*/
|
||||
export function getCommandSnippetGroupList() {
|
||||
return axios.get<Array<CommandSnippetGroupQueryResponse>>('/terminal/command-snippet-group/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除命令片段分组
|
||||
*/
|
||||
export function deleteCommandSnippetGroup(id: number) {
|
||||
return axios.delete('/terminal/command-snippet-group/delete', { params: { id } });
|
||||
}
|
||||
|
||||
68
orion-visor-ui/src/api/terminal/command-snippet.ts
Normal file
68
orion-visor-ui/src/api/terminal/command-snippet.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import type { CommandSnippetGroupQueryResponse } from './command-snippet-group';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 命令片段创建请求
|
||||
*/
|
||||
export interface CommandSnippetCreateRequest {
|
||||
groupId?: number;
|
||||
name?: string;
|
||||
command?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令片段更新请求
|
||||
*/
|
||||
export interface CommandSnippetUpdateRequest extends CommandSnippetCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令片段查询响应
|
||||
*/
|
||||
export interface CommandSnippetQueryResponse extends CommandSnippetQueryResponseExtra {
|
||||
id: number;
|
||||
groupId: number;
|
||||
name: string;
|
||||
command: string;
|
||||
}
|
||||
|
||||
export interface CommandSnippetQueryResponseExtra {
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令片段查询响应
|
||||
*/
|
||||
export interface CommandSnippetWrapperResponse {
|
||||
groups: Array<CommandSnippetGroupQueryResponse>;
|
||||
ungroupedItems: Array<CommandSnippetQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建命令片段
|
||||
*/
|
||||
export function createCommandSnippet(request: CommandSnippetCreateRequest) {
|
||||
return axios.post('/terminal/command-snippet/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新命令片段
|
||||
*/
|
||||
export function updateCommandSnippet(request: CommandSnippetUpdateRequest) {
|
||||
return axios.put('/terminal/command-snippet/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部命令片段
|
||||
*/
|
||||
export function getCommandSnippetList() {
|
||||
return axios.get<CommandSnippetWrapperResponse>('/terminal/command-snippet/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除命令片段
|
||||
*/
|
||||
export function deleteCommandSnippet(id: number) {
|
||||
return axios.delete('/terminal/command-snippet/delete', { params: { id } });
|
||||
}
|
||||
54
orion-visor-ui/src/api/terminal/path-bookmark-group.ts
Normal file
54
orion-visor-ui/src/api/terminal/path-bookmark-group.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { PathBookmarkQueryResponse } from './path-bookmark';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 路径书签分组创建请求
|
||||
*/
|
||||
export interface PathBookmarkGroupCreateRequest {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径书签分组更新请求
|
||||
*/
|
||||
export interface PathBookmarkGroupUpdateRequest extends PathBookmarkGroupCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径书签分组查询响应
|
||||
*/
|
||||
export interface PathBookmarkGroupQueryResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
items: Array<PathBookmarkQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建路径书签分组
|
||||
*/
|
||||
export function createPathBookmarkGroup(request: PathBookmarkGroupCreateRequest) {
|
||||
return axios.post('/terminal/path-bookmark-group/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新路径书签分组
|
||||
*/
|
||||
export function updatePathBookmarkGroup(request: PathBookmarkGroupUpdateRequest) {
|
||||
return axios.put('/terminal/path-bookmark-group/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部路径书签分组
|
||||
*/
|
||||
export function getPathBookmarkGroupList() {
|
||||
return axios.get<Array<PathBookmarkGroupQueryResponse>>('/terminal/path-bookmark-group/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除路径书签分组
|
||||
*/
|
||||
export function deletePathBookmarkGroup(id: number) {
|
||||
return axios.delete('/terminal/path-bookmark-group/delete', { params: { id } });
|
||||
}
|
||||
|
||||
70
orion-visor-ui/src/api/terminal/path-bookmark.ts
Normal file
70
orion-visor-ui/src/api/terminal/path-bookmark.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import type { PathBookmarkGroupQueryResponse } from './path-bookmark-group';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 路径标签创建请求
|
||||
*/
|
||||
export interface PathBookmarkCreateRequest {
|
||||
groupId?: number;
|
||||
name?: string;
|
||||
type?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径标签更新请求
|
||||
*/
|
||||
export interface PathBookmarkUpdateRequest extends PathBookmarkCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径标签查询响应
|
||||
*/
|
||||
export interface PathBookmarkQueryResponse extends PathBookmarkQueryResponseExtra {
|
||||
id: number;
|
||||
groupId: number;
|
||||
name: string;
|
||||
type: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface PathBookmarkQueryResponseExtra {
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径标签查询响应
|
||||
*/
|
||||
export interface PathBookmarkWrapperResponse {
|
||||
groups: Array<PathBookmarkGroupQueryResponse>;
|
||||
ungroupedItems: Array<PathBookmarkQueryResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建路径标签
|
||||
*/
|
||||
export function createPathBookmark(request: PathBookmarkCreateRequest) {
|
||||
return axios.post('/terminal/path-bookmark/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新路径标签
|
||||
*/
|
||||
export function updatePathBookmark(request: PathBookmarkUpdateRequest) {
|
||||
return axios.put('/terminal/path-bookmark/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询路径标签
|
||||
*/
|
||||
export function getPathBookmarkList() {
|
||||
return axios.get<PathBookmarkWrapperResponse>('/terminal/path-bookmark/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除路径标签
|
||||
*/
|
||||
export function deletePathBookmark(id: number) {
|
||||
return axios.delete('/terminal/path-bookmark/delete', { params: { id } });
|
||||
}
|
||||
115
orion-visor-ui/src/api/terminal/terminal-connect-log.ts
Normal file
115
orion-visor-ui/src/api/terminal/terminal-connect-log.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import type { ClearRequest, DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* 终端连接日志查询请求
|
||||
*/
|
||||
export interface TerminalConnectLogQueryRequest extends Pagination, OrderDirection {
|
||||
id?: number;
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
hostAddress?: string;
|
||||
type?: string;
|
||||
sessionId?: string;
|
||||
status?: string;
|
||||
startTimeRange?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端连接日志清理请求
|
||||
*/
|
||||
export interface TerminalConnectLogClearRequest extends TerminalConnectLogQueryRequest, ClearRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端连接日志查询响应
|
||||
*/
|
||||
export interface TerminalConnectLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
hostId: number;
|
||||
hostName: string;
|
||||
hostAddress: string;
|
||||
type: string;
|
||||
sessionId: string;
|
||||
status: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
extra: TerminalConnectLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端连接日志拓展对象
|
||||
*/
|
||||
export interface TerminalConnectLogExtra {
|
||||
traceId: string;
|
||||
channel: string;
|
||||
channelId: string;
|
||||
sessionId: string;
|
||||
address: string;
|
||||
location: string;
|
||||
userAgent: string;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询终端连接日志
|
||||
*/
|
||||
export function getTerminalConnectLogPage(request: TerminalConnectLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalConnectLogQueryResponse>>('/terminal/terminal-connect-log/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部终端连接会话
|
||||
*/
|
||||
export function getTerminalConnectSessions(request: TerminalConnectLogQueryRequest) {
|
||||
return axios.post<Array<TerminalConnectLogQueryResponse>>('/terminal/terminal-connect-log/sessions', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户最近连接的主机
|
||||
*/
|
||||
export function getLatestConnectHostId(type: string, limit: number) {
|
||||
return axios.post<Array<number>>('/terminal/terminal-connect-log/latest-connect', {
|
||||
type,
|
||||
limit
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除终端连接日志
|
||||
*/
|
||||
export function deleteTerminalConnectLog(idList: Array<number>) {
|
||||
return axios.delete('/terminal/terminal-connect-log/delete', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询终端连接日志数量
|
||||
*/
|
||||
export function getTerminalConnectLogCount(request: TerminalConnectLogQueryRequest) {
|
||||
return axios.post<number>('/terminal/terminal-connect-log/count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空终端连接日志
|
||||
*/
|
||||
export function clearTerminalConnectLog(request: TerminalConnectLogClearRequest) {
|
||||
return axios.post<number>('/terminal/terminal-connect-log/clear', request, {
|
||||
timeout: 60000,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制断开终端连接
|
||||
*/
|
||||
export function hostForceOffline(request: TerminalConnectLogQueryRequest) {
|
||||
return axios.put('/terminal/terminal-connect-log/force-offline', request);
|
||||
}
|
||||
104
orion-visor-ui/src/api/terminal/terminal-sftp.ts
Normal file
104
orion-visor-ui/src/api/terminal/terminal-sftp.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import { httpBaseUrl } from '@/utils/env';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 查询请求
|
||||
*/
|
||||
export interface TerminalSftpLogQueryRequest extends Pagination, OrderDirection {
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
type?: string;
|
||||
result?: number;
|
||||
startTimeRange?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 查询响应
|
||||
*/
|
||||
export interface TerminalSftpLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
hostId: number;
|
||||
hostName: string;
|
||||
hostAddress: string;
|
||||
address: string;
|
||||
location: string;
|
||||
userAgent: string;
|
||||
paths: string[];
|
||||
type: string;
|
||||
result: string;
|
||||
startTime: number;
|
||||
extra: TerminalSftpLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 拓展对象
|
||||
*/
|
||||
export interface TerminalSftpLogExtra {
|
||||
mod: number;
|
||||
target: string;
|
||||
maxCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询 SFTP 操作日志
|
||||
*/
|
||||
export function getTerminalSftpLogPage(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalSftpLogQueryResponse>>('/terminal/terminal-sftp/query-log', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 SFTP 操作日志数量
|
||||
*/
|
||||
export function getTerminalSftpLogCount(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<number>('/terminal/terminal-sftp/log-count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 SFTP 操作日志
|
||||
*/
|
||||
export function deleteTerminalSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/terminal/terminal-sftp/delete-log', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 SFTP 文件内容
|
||||
*/
|
||||
export function getSftpFileContent(token: string) {
|
||||
return axios.get<string>('/terminal/terminal-sftp/get-content', {
|
||||
unwrap: true,
|
||||
params: { token },
|
||||
timeout: 60000
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 SFTP 文件内容
|
||||
*/
|
||||
export function setSftpFileContent(token: string, content: string) {
|
||||
const formData = new FormData();
|
||||
formData.append('token', token);
|
||||
formData.append('file', new File([content], Date.now() + '', { type: 'text/plain' }));
|
||||
return axios.post<boolean>('/terminal/terminal-sftp/set-content', formData, {
|
||||
timeout: 60000,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
export function getDownloadTransferUrl(channelId: string, transferToken: string) {
|
||||
return `${httpBaseUrl}/terminal/terminal-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
|
||||
}
|
||||
46
orion-visor-ui/src/api/terminal/terminal.ts
Normal file
46
orion-visor-ui/src/api/terminal/terminal.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { TerminalTheme } from '@/views/terminal/interfaces';
|
||||
import axios from 'axios';
|
||||
import { createAppWebSocket } from '@/utils/http';
|
||||
|
||||
// 终端访问请求
|
||||
export interface TerminalAccessRequest {
|
||||
hostId?: number;
|
||||
connectType?: string;
|
||||
extra?: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机终端主题
|
||||
*/
|
||||
export function getTerminalThemes() {
|
||||
return axios.get<Array<TerminalTheme>>('/terminal/terminal/themes');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机终端 accessToken
|
||||
*/
|
||||
export function getTerminalAccessToken(request: TerminalAccessRequest) {
|
||||
return axios.post<string>('/terminal/terminal/access', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机终端 transferToken
|
||||
*/
|
||||
export function getTerminalTransferToken() {
|
||||
return axios.get<string>('/terminal/terminal/transfer');
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开主机终端 websocket
|
||||
*/
|
||||
export const openTerminalAccessChannel = (protocol: string, accessToken: string) => {
|
||||
return createAppWebSocket(`/terminal/access/${protocol}/${accessToken}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开主机传输 websocket
|
||||
*/
|
||||
export const openTerminalTransferChannel = (accessToken: string) => {
|
||||
return createAppWebSocket(`/terminal/transfer/${accessToken}`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user