From 81e2731b5ec2c05c2e1a54f11a3eeec3a5e0c310 Mon Sep 17 00:00:00 2001 From: jialin Date: Thu, 24 Oct 2024 23:22:47 +0800 Subject: [PATCH] chore: add button for copy logs --- config/config.ts | 2 +- src/components/logs-viewer/index.less | 14 ++++++++++++++ src/components/logs-viewer/index.tsx | 8 ++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config/config.ts b/config/config.ts index 18abf24..3654689 100644 --- a/config/config.ts +++ b/config/config.ts @@ -14,7 +14,7 @@ const isProduction = env === 'production'; const t = Date.now(); export default defineConfig({ proxy: { - ...proxy('http://192.168.50.2:8088/') + ...proxy() }, history: { type: 'hash' diff --git a/src/components/logs-viewer/index.less b/src/components/logs-viewer/index.less index 2e23484..b80ec75 100644 --- a/src/components/logs-viewer/index.less +++ b/src/components/logs-viewer/index.less @@ -1,4 +1,18 @@ .logs-viewer-wrap-w2 { + position: relative; + + .copy { + position: absolute; + top: 10px; + right: 10px; + z-index: 100; + + button { + background-color: rgba(255, 255, 255, 90%); + border: none; + } + } + .wrap { padding: 5px 0 5px 10px; background-color: var(--color-logs-bg); diff --git a/src/components/logs-viewer/index.tsx b/src/components/logs-viewer/index.tsx index 281960b..56eefb1 100644 --- a/src/components/logs-viewer/index.tsx +++ b/src/components/logs-viewer/index.tsx @@ -4,6 +4,7 @@ import '@xterm/xterm/css/xterm.css'; import classNames from 'classnames'; import _ from 'lodash'; import { memo, useCallback, useEffect, useRef, useState } from 'react'; +import CopyButton from '../copy-button'; import './index.less'; import useParseAnsi from './parse-ansi'; @@ -119,6 +120,13 @@ const LogsViewer: React.FC = (props) => { return (
+ + item.content).join('\n')} + type="default" + size="small" + > +