⚡ 拆分模块.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { PathBookmarkGroupQueryResponse } from '@/api/asset/path-bookmark-group';
|
||||
import type { PathBookmarkGroupQueryResponse } from './path-bookmark-group';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import qs from 'query-string';
|
||||
/**
|
||||
* SFTP 操作日志 查询请求
|
||||
*/
|
||||
export interface HostSftpLogQueryRequest extends Pagination {
|
||||
export interface TerminalSftpLogQueryRequest extends Pagination {
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
type?: string;
|
||||
@@ -18,7 +18,7 @@ export interface HostSftpLogQueryRequest extends Pagination {
|
||||
/**
|
||||
* SFTP 操作日志 查询响应
|
||||
*/
|
||||
export interface HostSftpLogQueryResponse extends TableData {
|
||||
export interface TerminalSftpLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
@@ -32,13 +32,13 @@ export interface HostSftpLogQueryResponse extends TableData {
|
||||
type: string;
|
||||
result: string;
|
||||
startTime: number;
|
||||
extra: HostSftpLogExtra;
|
||||
extra: TerminalSftpLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 拓展对象
|
||||
*/
|
||||
export interface HostSftpLogExtra {
|
||||
export interface TerminalSftpLogExtra {
|
||||
mod: number;
|
||||
target: string;
|
||||
maxCount: number;
|
||||
@@ -47,15 +47,15 @@ export interface HostSftpLogExtra {
|
||||
/**
|
||||
* 分页查询 SFTP 操作日志
|
||||
*/
|
||||
export function getHostSftpLogPage(request: HostSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<HostSftpLogQueryResponse>>('/asset/host-sftp/query-log', request);
|
||||
export function getTerminalSftpLogPage(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalSftpLogQueryResponse>>('/asset/terminal-sftp/query-log', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 SFTP 操作日志
|
||||
*/
|
||||
export function deleteHostSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/host-sftp/delete-log', {
|
||||
export function deleteTerminalSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/asset/terminal-sftp/delete-log', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
@@ -67,7 +67,7 @@ export function deleteHostSftpLog(idList: Array<number>) {
|
||||
* 获取 SFTP 文件内容
|
||||
*/
|
||||
export function getSftpFileContent(token: string) {
|
||||
return axios.get<string>('/asset/host-sftp/get-content', {
|
||||
return axios.get<string>('/asset/terminal-sftp/get-content', {
|
||||
unwrap: true,
|
||||
params: { token },
|
||||
timeout: 60000
|
||||
@@ -81,7 +81,7 @@ 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>('/asset/host-sftp/set-content', formData, {
|
||||
return axios.post<boolean>('/asset/terminal-sftp/set-content', formData, {
|
||||
timeout: 60000,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
@@ -93,5 +93,5 @@ export function setSftpFileContent(token: string, content: string) {
|
||||
* 下载文件
|
||||
*/
|
||||
export function getDownloadTransferUrl(channelId: string, transferToken: string) {
|
||||
return `${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
|
||||
return `${httpBaseUrl}/asset/terminal-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import type { TerminalTheme, TerminalThemeSchema } from '@/api/asset/terminal';
|
||||
import { getTerminalThemes } from '@/api/asset/terminal';
|
||||
import { defineStore } from 'pinia';
|
||||
import { getPreference, updatePreference } from '@/api/user/preference';
|
||||
import { getLatestConnectHostId } from '@/api/asset/terminal-connect-log';
|
||||
import { nextId } from '@/utils';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { PanelSessionType, TerminalTabs } from '@/views/host/terminal/types/const';
|
||||
@@ -128,10 +129,15 @@ export default defineStore('terminal', {
|
||||
if (this.hosts.hostList?.length) {
|
||||
return;
|
||||
}
|
||||
// 查询授权主机
|
||||
const { data } = await getCurrentAuthorizedHost('SSH');
|
||||
Object.keys(data).forEach(k => {
|
||||
this.hosts[k as keyof AuthorizedHostQueryResponse] = data[k as keyof AuthorizedHostQueryResponse] as any;
|
||||
});
|
||||
this.hosts.latestHosts = [];
|
||||
// 查询最近连接的主机
|
||||
const { data: latestHosts } = await getLatestConnectHostId('SSH', 30);
|
||||
this.hosts.latestHosts = latestHosts;
|
||||
},
|
||||
|
||||
// 打开会话
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
position="br"
|
||||
type="warning"
|
||||
@ok="deleteSelectRows">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:host-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:terminal-sftp-log:management:delete']"
|
||||
type="primary"
|
||||
status="danger"
|
||||
:disabled="selectedKeys.length === 0">
|
||||
@@ -164,7 +164,7 @@
|
||||
position="left"
|
||||
type="warning"
|
||||
@ok="deleteRow(record)">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:host-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'asset:terminal-sftp-log:management:delete']"
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger">
|
||||
@@ -184,9 +184,9 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { HostSftpLogQueryRequest, HostSftpLogQueryResponse } from '@/api/asset/host-sftp';
|
||||
import type { TerminalSftpLogQueryRequest, TerminalSftpLogQueryResponse } from '@/api/asset/terminal-sftp';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { getHostSftpLogPage, deleteHostSftpLog } from '@/api/asset/host-sftp';
|
||||
import { getTerminalSftpLogPage, deleteTerminalSftpLog } from '@/api/asset/terminal-sftp';
|
||||
import { sftpOperatorTypeKey, sftpOperatorResultKey, SftpOperatorType, showPathMaxCount } from '../types/const';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
@@ -203,9 +203,9 @@
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
|
||||
const tableRenderData = ref<Array<HostSftpLogQueryResponse>>([]);
|
||||
const tableRenderData = ref<Array<TerminalSftpLogQueryResponse>>([]);
|
||||
const selectedKeys = ref<Array<number>>([]);
|
||||
const formModel = reactive<HostSftpLogQueryRequest>({
|
||||
const formModel = reactive<TerminalSftpLogQueryRequest>({
|
||||
userId: undefined,
|
||||
hostId: undefined,
|
||||
type: undefined,
|
||||
@@ -214,11 +214,11 @@
|
||||
});
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: HostSftpLogQueryRequest) => {
|
||||
const doFetchTableData = async (request: TerminalSftpLogQueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 查询
|
||||
const { data } = await getHostSftpLogPage(request);
|
||||
const { data } = await getTerminalSftpLogPage(request);
|
||||
// 设置最大数量
|
||||
data.rows.forEach(s => {
|
||||
s.extra.maxCount = showPathMaxCount;
|
||||
@@ -244,7 +244,7 @@
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteHostSftpLog(selectedKeys.value);
|
||||
await deleteTerminalSftpLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
@@ -256,11 +256,11 @@
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async (record: HostSftpLogQueryResponse) => {
|
||||
const deleteRow = async (record: TerminalSftpLogQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteHostSftpLog([record.id]);
|
||||
await deleteTerminalSftpLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { openSftpCreateModalKey, openSftpMoveModalKey, openSftpChmodModalKey, openSftpUploadModalKey } from '../../types/const';
|
||||
import { getSftpFileContent, setSftpFileContent } from '@/api/asset/host-sftp';
|
||||
import { getSftpFileContent, setSftpFileContent } from '@/api/asset/terminal-sftp';
|
||||
import { isString } from '@/utils/is';
|
||||
import SftpTableHeader from './sftp-table-header.vue';
|
||||
import SftpTable from './sftp-table.vue';
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { SftpTransferItem } from '../types/define';
|
||||
import { TransferStatus } from '../types/const';
|
||||
import { getFileName, openDownloadFile } from '@/utils/file';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { getDownloadTransferUrl } from '@/api/asset/host-sftp';
|
||||
import { getDownloadTransferUrl } from '@/api/asset/terminal-sftp';
|
||||
import SftpTransferHandler from './sftp-transfer-handler';
|
||||
|
||||
// sftp 下载器实现
|
||||
|
||||
Reference in New Issue
Block a user