feat: 快捷键设置.

This commit is contained in:
lijiahang
2024-01-17 19:28:45 +08:00
parent fc28391927
commit 9d8fddd9ae
6 changed files with 4534 additions and 6867 deletions

View File

@@ -36,6 +36,8 @@
"axios": "^0.24.0", "axios": "^0.24.0",
"dayjs": "^1.11.5", "dayjs": "^1.11.5",
"echarts": "^5.4.0", "echarts": "^5.4.0",
"file-saver": "^2.0.5",
"html2canvas": "^1.4.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mitt": "^3.0.0", "mitt": "^3.0.0",
"monaco-editor": "^0.44.0", "monaco-editor": "^0.44.0",
@@ -60,6 +62,7 @@
"@arco-plugins/vite-vue": "^1.4.5", "@arco-plugins/vite-vue": "^1.4.5",
"@commitlint/cli": "^17.1.2", "@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0", "@commitlint/config-conventional": "^17.1.0",
"@types/file-saver": "^2.0.7",
"@types/lodash": "^4.14.186", "@types/lodash": "^4.14.186",
"@types/mockjs": "^1.0.7", "@types/mockjs": "^1.0.7",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",

11361
orion-ops-ui/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@
<!-- 内容区域 --> <!-- 内容区域 -->
<div class="terminal-setting-body setting-body"> <div class="terminal-setting-body setting-body">
<!-- 提示 --> <!-- 提示 -->
<a-alert class="mb16">点击保存按钮后需要刷新页面生效 (设置时需要避免浏览器内置快捷键)</a-alert> <a-alert class="mb16">点击保存按钮后需要刷新页面生效 (恢复默认配置后也需要点击保存按钮) (设置时需要避免使用浏览器内置快捷键)</a-alert>
<a-space class="action-container" size="mini"> <a-space class="action-container" size="mini">
<!-- 是否启用 --> <!-- 是否启用 -->
<a-switch v-model="value" <a-switch v-model="value"

View File

@@ -54,6 +54,7 @@
import useLoading from '@/hooks/loading'; import useLoading from '@/hooks/loading';
import { useDebounceFn } from '@vueuse/core'; import { useDebounceFn } from '@vueuse/core';
import { addEventListen, removeEventListen } from '@/utils/event'; import { addEventListen, removeEventListen } from '@/utils/event';
import { Message } from '@arco-design/web-vue';
import TerminalShortcutKeysBlock from './terminal-shortcut-keys-block.vue'; import TerminalShortcutKeysBlock from './terminal-shortcut-keys-block.vue';
import TerminalShortcutActionBlock from './terminal-shortcut-action-block.vue'; import TerminalShortcutActionBlock from './terminal-shortcut-action-block.vue';
@@ -166,6 +167,7 @@
enabled: enabled.value, enabled: enabled.value,
keys: shortcutKeys.value keys: shortcutKeys.value
} as TerminalShortcutSetting); } as TerminalShortcutSetting);
Message.success('保存成功');
} catch (e) { } catch (e) {
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -93,7 +93,6 @@
const session = ref<ITerminalSession>(); const session = ref<ITerminalSession>();
// TODO // TODO
// 截屏
// sftp // sftp
// 代码片段 // 代码片段

View File

@@ -11,7 +11,7 @@
<terminal-left-sidebar /> <terminal-left-sidebar />
</div> </div>
<!-- 内容区域 --> <!-- 内容区域 -->
<div class="host-layout-content"> <div class="host-layout-content" ref="content">
<!-- 主机加载中骨架 --> <!-- 主机加载中骨架 -->
<loading-skeleton v-if="contentLoading" /> <loading-skeleton v-if="contentLoading" />
<!-- 终端内容区域 --> <!-- 终端内容区域 -->
@@ -19,7 +19,7 @@
</div> </div>
<!-- 右侧操作栏 --> <!-- 右侧操作栏 -->
<div class="host-layout-right"> <div class="host-layout-right">
<terminal-right-sidebar /> <terminal-right-sidebar @screenshot="screenshotTerminal" />
</div> </div>
</main> </main>
</div> </div>
@@ -41,8 +41,11 @@
import TerminalRightSidebar from './components/layout/terminal-right-sidebar.vue'; import TerminalRightSidebar from './components/layout/terminal-right-sidebar.vue';
import TerminalContent from './components/layout/terminal-content.vue'; import TerminalContent from './components/layout/terminal-content.vue';
import LoadingSkeleton from './components/layout/loading-skeleton.vue'; import LoadingSkeleton from './components/layout/loading-skeleton.vue';
import html2canvas from 'html2canvas';
import { saveAs } from 'file-saver';
import './assets/styles/layout.less'; import './assets/styles/layout.less';
import 'xterm/css/xterm.css'; import 'xterm/css/xterm.css';
import { Message } from '@arco-design/web-vue';
const terminalStore = useTerminalStore(); const terminalStore = useTerminalStore();
const dictStore = useDictStore(); const dictStore = useDictStore();
@@ -51,6 +54,7 @@
const originTitle = document.title; const originTitle = document.title;
const render = ref(false); const render = ref(false);
const content = ref();
// 关闭视口处理 // 关闭视口处理
const handleBeforeUnload = (event: any) => { const handleBeforeUnload = (event: any) => {
@@ -58,6 +62,30 @@
event.returnValue = confirm('系统可能不会保存您所做的更改'); event.returnValue = confirm('系统可能不会保存您所做的更改');
}; };
// 终端截图
// FIXME test 水印
const screenshotTerminal = async () => {
try {
console.log(content.value);
const canvas = await html2canvas(content.value, {
useCORS: true,
backgroundColor: 'transparent',
});
console.log(canvas);
const blob = await new Promise((resolve, reject) => {
canvas.toBlob((blob) => {
if (!blob) {
reject(new Error('截屏失败'));
}
resolve(blob);
}, 'image/png');
});
saveAs(blob, `screenshot-${Date.now()}.png`);
} catch (e) {
Message.error('保存失败');
}
};
// 加载用户终端偏好 // 加载用户终端偏好
onBeforeMount(async () => { onBeforeMount(async () => {
await terminalStore.fetchPreference(); await terminalStore.fetchPreference();